forked from ENCODE-DCC/snovault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
38 lines (32 loc) · 892 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
const gulp = require('gulp');
const log = require('fancy-log');
const webpack = require('webpack');
const setProduction = function (cb) {
process.env.NODE_ENV = 'production';
if (cb) {
cb();
}
};
const webpackOnBuild = function (done) {
return function (err, stats) {
if (err) {
throw new log.error(err);
}
log(stats.toString({
colors: true
}));
if (done) { done(err); }
};
};
const webpackSetup = function (cb) {
var webpackConfig = require('./webpack.config.js');
webpack(webpackConfig).run(webpackOnBuild(cb));
};
const watch = function (cb) {
var 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));