Весь файл gulpfile.js
/**
* gulp - Сборка пакета (просто ввести в консоле)
* gulp archive - Создаёт zip
*/
const { series, parallel } = require('gulp'),
gulp = require('gulp'),
vers = require('./app/manifest.json').version,
babel = require('gulp-babel'),
uglify = require('gulp-uglify'),
cleanCSS = require('gulp-clean-css'),
htmlmin = require('gulp-htmlmin'),
del = require('del'),
zip = require('gulp-zip');
function remove(cb) {
// del(['dist/**/*']).then(paths => {
// console.log('Удалены файлы и папки:\n', paths.join('\n'));
// });
del(['dist/*.html', 'dist/manifest.json', 'dist/css/*.css', 'dist/img/*.png', 'dist/js/*.js', 'dist/language/en/*.json', 'dist/language/ru/*.json']);
cb();
}
function styles(done) {
gulp.src('app/css/**/*.css').pipe(cleanCSS()).pipe(gulp.dest('dist/css'));
done();
}
function html(done) {
gulp.src('app/*.html').pipe(htmlmin({ collapseWhitespace: true, removeComments: true, minifyCSS: true })).pipe(gulp.dest('dist'));
done();
}
function script(done) {
gulp.src('app/js/**/*.js')
.pipe(babel({
presets: ['@babel/env']
}))
.pipe(uglify())
.pipe(gulp.dest('dist/js'));
done();
}
function manifest(done) {
gulp.src('app/manifest.json').pipe(gulp.dest('dist'));
done();
}
function lang(done) {
gulp.src('app/language/**/**/*').pipe(gulp.dest('dist/language'));
done();
}
function images(done) {
gulp.src('app/img/**/*').pipe(gulp.dest('dist/img'));
done();
}
gulp.task('archive', () =>
gulp.src('dist/**/*')
.pipe(zip(`name_v${vers}.zip`))
.pipe(gulp.dest('versions'))
);
function archive(cb) {
gulp.src('dist/**/*').pipe(zip(`name_v${vers}.zip`)).pipe(gulp.dest('versions'));
cb();
}
exports.default = series(remove, parallel(script, styles, html, images, lang, manifest)/*, 'archive'*/);
// exports.default = series(remove, parallel(script, styles, html, images, lang, manifest), archive);