-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgulpfile.babel.js
53 lines (47 loc) · 1.36 KB
/
gulpfile.babel.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
import gulp from 'gulp'
import gutil from 'gulp-util'
import del from 'del'
import WebpackDevServer from "webpack-dev-server"
import webpack from "webpack"
const path = require('path');
const DEV_PORT = 4000, PROD_PORT = 80
const server = (webpackPath, cb)=> {
let webpackConfig = require(webpackPath)
let myConfig = Object.create(webpackConfig)
myConfig.devtool = 'eval-source-map'
myConfig.debug = true;
new WebpackDevServer(webpack(myConfig), {
hot: true,
inline: true,
publicPath: '/' + myConfig.output.publicPath,
stats: {
colors: true
}
}).listen(DEV_PORT, "127.0.0.1", err => {
if (err) throw new gutil.PluginError("webpack-dev-server", err)
gutil.log("[webpack-dev-server]", "==> http://127.0.0.1:" + DEV_PORT)
});
cb();
};
const build = (webpackPath, cb)=> {
let webpackConfig = require(webpackPath)
let myConfig = Object.create(webpackConfig)
webpack(myConfig, function (err, stats) {
if (err) throw new gutil.PluginError("webpack", err)
gutil.log("[webpack]", stats.toString({
// output options
}));
cb()
})
};
gulp.task('server-dev', cb => {
server(path.join(__dirname, ''), cb);
});
gulp.task('server-build', cb => {
build(path.join(__dirname, ''), cb);
});
gulp.task('base-dev', cb => {
});
gulp.task('base-build', cb => {
});
gulp.task('clean', cb => del([path.join(__dirname, '/dist/*')]));