-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
executable file
·43 lines (39 loc) · 1.08 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
const gulp = require("gulp");
const open = require("gulp-open");
const plumber = require("gulp-plumber");
const os = require("os");
const webpack = require("webpack-stream");
const webpackConfig = require("./source/webpack.config.js");
const getServer = require("./server/app");
const browser =
os.platform() === "linux"
? "google-chrome"
: os.platform() === "darwin"
? "Microsoft Edge"
: os.platform() === "win32"
? "msedge"
: "chrome";
// mac: "google chrome"
//本地服务
gulp.task("server", function () {
let port = 8084;
getServer(port);
let options = {
uri: "http://localhost:" + port,
app: browser,
};
gulp.src(__filename).pipe(open(options));
});
//前端开发构建
gulp.task("dev", function () {
return gulp
.src(__filename)
.pipe(plumber())
.pipe(webpack(webpackConfig("dev")))
.pipe(gulp.dest("source/dist/"));
});
// 监听修改 自动构建
gulp.task("watch", gulp.series('dev', 'server'), function () {
// gulp.run(["dev", "server"]);
gulp.watch(["source/src/**/*.js", "source/src/**/*.css"], ['dev']);
});