-
Notifications
You must be signed in to change notification settings - Fork 51
/
gulpfile.js
39 lines (33 loc) · 922 Bytes
/
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
38
39
const gulp = require('gulp');
const log = require('fancy-log');
const webpack = require('webpack');
const setProduction = (cb) => {
process.env.NODE_ENV = 'production';
if (cb) {
cb();
}
};
const webpackOnBuild = done => (err, stats) => {
if (err) {
throw new log.error(err);
}
log(stats.toString({
colors: true,
excludeAssets: [/.*ckeditor.*/],
}));
if (done) {
done(err);
}
};
const webpackSetup = (cb) => {
const webpackConfig = require('./webpack.config.js');
webpack(webpackConfig).run(webpackOnBuild(cb));
};
const watch = (cb) => {
const webpackConfig = require('./webpack.config.js');
webpack(webpackConfig).watch(300, webpackOnBuild(cb));
};
const series = gulp.series;
gulp.task('default', series(webpackSetup, watch));
gulp.task('dev', series('default'));
gulp.task('build', series(setProduction, webpackSetup));