File size: 1,054 Bytes
181e22f | 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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | /* eslint-disable no-console */
import gulp from 'gulp';
import nodemon from 'gulp-nodemon';
import webpack from 'webpack';
function envProd(cb) {
process.env.NODE_ENV = 'production';
cb();
}
function envDev(cb) {
process.env.NODE_ENV = 'development';
cb();
}
function build(cb) {
const config = require('./config/webpack.config.js');
webpack(config, (err, stats) => {
if (err) {
console.error(err.stack || err);
if (err.details) {
console.error(err.details);
}
return;
}
const info = stats.toJson();
if (stats.hasErrors()) {
console.error(info.errors);
}
if (stats.hasWarnings()) {
console.warn(info.warnings);
}
console.log('[webpack]', stats.toString({ colors: true }));
cb();
});
}
function server(cb) {
nodemon({
script: 'src/index.js',
ext: 'js,json',
watch: ['./'],
delay: 500,
});
cb();
}
const dev = gulp.series(envDev, server);
exports.dev = dev;
exports.build = gulp.series(envProd, build);
exports.default = dev;
|