-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
66 lines (56 loc) · 1.3 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
const del = require("del");
const gulp = require("gulp");
const webpack = require("webpack");
const webpack_stream = require("webpack-stream");
const eslint = require("gulp-eslint");
/**
* Define public tasks of gulp
*/
/**
* A public task to build a package in production mode
*/
exports.build = gulp.series(clean, gulp.parallel(eslintJS, buildJS));
/**
* End public tasks' definition
*/
/**
* Define private tasks of gulp
*/
/**
* A private task to clean old files before building new ones
*/
function clean() {
return del(["./dist/*"]);
}
/**
* A private task to run eslint check for JS code
*/
function eslintJS() {
return gulp
.src("./src/**/*.js", { base: "src" })
.pipe(
eslint({
configFile: "./.eslintrc.js"
})
)
.pipe(eslint.format());
}
/**
* A private code to build JS code
*/
function buildJS() {
let output_dir = "./dist/";
let webpack_config = require("./webpack.config.js");
return gulp
.src("./src/**/*.js", { base: "src" })
.pipe(webpack_stream(webpack_config, webpack))
.pipe(gulp.dest(output_dir))
.on("error", error => log(error));
}
/**
* End private tasks' definition
*/
// Wrapper of process.stdout.write.
function log(d) {
process.stdout.write(d + "\n");
}