forked from u-wave/web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
56 lines (49 loc) · 1.2 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* eslint-disable global-require */
const gulp = require('gulp');
const webpack = require('webpack');
const rimraf = require('rimraf');
const env = require('./tasks/env');
const js = require('./tasks/js');
const serve = require('./tasks/serve');
function setWatching(done) {
env.watch = true;
done();
}
function cleanPublic(done) {
rimraf('public', done);
}
function cleanEs(done) {
rimraf('es', done);
}
function cleanLib(done) {
rimraf('lib', done);
}
const clean = gulp.parallel(cleanPublic, cleanEs, cleanLib);
const start = gulp.series(setWatching, serve.serve);
const build = gulp.parallel(js.locales, js.babel);
function prod(done) {
// Load this later because it adds require compile hooks.
// Those don't need to run on the above imports.
const wpConfig = require('./webpack.config');
const compiler = webpack(wpConfig);
compiler.run((err, stats) => {
if (err) {
compiler.purgeInputFileSystem();
done(err);
} else {
process.stdout.write(stats.toString({
colors: true,
}));
done();
}
});
}
module.exports = {
setWatching,
serve: serve.serve,
start,
build,
clean,
default: build,
prod: gulp.series(cleanPublic, build, prod),
};