-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
37 lines (31 loc) · 1.24 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const gulp = require("gulp");
const minify = require('gulp-minify');
const PluginError = require('plugin-error');
const log = require('fancy-log');
const webpack = require("webpack");
const del = require('del');
const argv = require('minimist')(process.argv.slice(2));
gulp.task("node_modules-webpack", (done) => {
const config = require("./webpack.config.js");
config.context = `${__dirname}`;
config.mode = argv.mode ? argv.mode : 'production';
return webpack(config, (err, stats) => {
const statsJson = stats.toJson();
if (err || (statsJson.errors && statsJson.errors.length)) {
statsJson.errors.forEach(webpackError => {
log.error(`Error (webpack): ${webpackError}`);
});
throw new PluginError('webpack', JSON.stringify(err || statsJson.errors));
}
log('[webpack]', stats.toString());
done();
});
});
gulp.task('compress', function(done) {
gulp.src(['./src/**/*.js']).pipe(minify({ext: {min: '.js'}, noSource: true})).pipe(gulp.dest('out'));
done();
});
gulp.task("clean", (done) => {
return del('out', done);
});
gulp.task("build", gulp.series("clean", "node_modules-webpack", 'compress'));