-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
57 lines (43 loc) · 1.04 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
var gulp = require('gulp');
var del = require('del');
var connect = require('gulp-connect');
var webpack = require('gulp-webpack');
var webpackConfig = require('./webpack.config.js');
var port = process.env.PORT || 8080;
var reloadPort = process.env.RELOAD_PORT || 35729;
function webpackFor(target) {
del([target])
configs = webpackConfig[target]
if (!Array.isArray(configs)) { configs = [configs] }
let promises = []
for (var i = 0; i < configs.length; i++) {
config = configs[i]
let promise = webpack(config)
.pipe(gulp.dest(target))
promises.push(promise)
}
return Promise.all(promises)
}
function build() {
return webpackFor('build')
}
function dist() {
return webpackFor('dist')
}
function serve() {
connect.server({
port: port,
livereload: {
port: reloadPort
}
});
}
function reloadJs() {
return gulp.src('./build/*.js')
.pipe(connect.reload());
}
function watch() {
gulp.watch(['./build/*.js'], reloadJs);
}
exports.dist = dist
exports.default = gulp.parallel(build, serve, watch)