-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
39 lines (30 loc) · 1.06 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
"use strict";
const gulp = require("gulp");
const gutil = require("gulp-util");
const open = require("gulp-open");
const rimraf = require("rimraf");
const webpack = require("webpack");
const WebpackDevServer = require("webpack-dev-server");
gulp.task("default", [ "dist" ]);
gulp.task("clean", cb => {
rimraf("./assets", cb);
});
gulp.task("dist", [ "clean" ], cb => {
webpack(require("./webpack.config-dist.js"), (err, stats) => {
if (err) throw new gutil.PluginError("webpack", err);
gutil.log("[webpack]", stats.toString());
});
});
gulp.task("dev", [ "clean" ], cb => {
const config = require("./webpack.config.js");
const compiler = webpack(config);
new WebpackDevServer(compiler, {
publicPath: config.output.publicPath,
proxy: config.devServer.proxy
}).listen(8080, "localhost", err => {
if (err) throw new gutil.PluginError("webpack-dev-server", err);
const uri = "http://localhost:8080/";
gutil.log("[webpack-dev-server]", uri);
gulp.src("").pipe(open({ uri }));
});
});