generated from stargately/web-onefx-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.babel.js
95 lines (84 loc) · 2.19 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
const del = require("del");
const gulp = require("gulp");
const gulpLivereload = require("gulp-livereload");
const logger = require("global/console");
const nodemon = require("gulp-nodemon");
const webpack = require("webpack");
const PluginError = require("plugin-error");
const log = require("fancy-log");
const less = require("gulp-less");
const webpackConfig = require("./webpack");
const clean = () => {
return del(["dist"]);
};
const watchServer = (done) => {
nodemon({
exec: "npm",
ext: "js json jsx yaml jade md ts tsx",
script: "start",
ignore: ["node_modules/", "dist/", "*translations/"],
});
done();
};
const compileJavascripts = (done) => {
webpack(webpackConfig, (err, stats) => {
if (err) {
throw new PluginError("webpack", err);
}
log.info("[webpack]", stats.toString({}));
done();
});
};
const watchJavascripts = (done) => {
gulp.watch(
[
"src/client/javascripts/**/*.js",
"src/client/javascripts/**/*.jsx",
"src/client/javascripts/**/*.ts",
"src/client/javascripts/**/*.tsx",
"src/client/javascripts/**/*.json",
"src/shared/**/*.js",
"src/shared/**/*.jsx",
"src/shared/**/*.ts",
"src/shared/**/*.tsx",
"src/shared/**/*.json",
],
compileJavascripts
);
done();
};
const watchLivereload = (done) => {
gulp.watch(["dist/**/*"], function onChange(e) {
gulpLivereload.changed(e.path);
});
done();
};
const compileLess = () => {
return gulp
.src("src/client/stylesheets/*.less")
.pipe(
less({
javascriptEnabled: true,
paths: ["./node_modules/antd/dist/antd.less"],
})
)
.pipe(gulp.dest("dist/stylesheets"));
};
const compileStatic = (done) => {
gulp
.src("src/client/static/**/*")
.on("error", function onError(err) {
logger.error(err);
})
.pipe(gulp.dest("dist"));
done();
};
const watchStatic = (done) => {
gulp.watch("src/client/static/**/*", compileStatic, compileLess);
done();
};
const build = gulp.parallel(compileJavascripts, compileLess, compileStatic);
const watch = gulp.parallel(build, watchJavascripts, watchStatic, watchServer);
export { build, watch };
export default watch;
/* eslint-enable */