This repository has been archived by the owner on Jan 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
80 lines (61 loc) · 1.56 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
const gulp = require('gulp');
const webpack = require('webpack');
const opn = require('opn');
const nodemon = require('gulp-nodemon');
const ssrWebpackConf = require('./build/webpack.ssr.config');
const webpackConfig = require('./build/webpack.config');
const errFun = (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);
}
}
const compile = (conf, done) => webpack(conf, (err, stats) => {
if (err || stats.hasErrors()) {
errFun(err, stats);
return;
}
done();
})
gulp.task('dev-ssr', gulp.series(
done => {
ssrWebpackConf.watch = true;
webpackConfig.watch = true;
done();
},
gulp.parallel(
done => compile(webpackConfig, done),
done => compile(ssrWebpackConf, done),
),
done => {
nodemon({
script: './server_render/index.js',
"ignore": [
'*.test.js',
'node_modules/*',
'*.map'
],
});
done();
},
done => {
opn(`http://${process.env.HOST}:${process.env.PORT}/`);
done();
},
));
gulp.task('bundle', gulp.series(
gulp.parallel(
done => compile(webpackConfig, done),
done => compile(ssrWebpackConf, done),
),
));