-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy pathgulpfile.babel.js
116 lines (104 loc) · 2.5 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
const gulp = require("gulp");
const gulpLivereload = require("gulp-livereload");
const logger = require("global/console");
const nodemon = require("gulp-nodemon");
const sass = require("gulp-sass");
const webpack = require("webpack");
const PluginError = require("plugin-error");
const log = require("fancy-log");
const less = require("gulp-less");
const webpackConfig = require("./webpack");
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 compileStylesheets = done => {
gulp
.src("src/client/stylesheets/*.scss")
.pipe(sass().on("error", sass.logError))
.pipe(gulp.dest("dist/stylesheets"));
done();
};
const watchStylesheets = done => {
gulp.watch("src/**/*.scss", compileStylesheets);
gulp.watch("src/**/*.less", compileLess);
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);
done();
};
const build = gulp.parallel(
compileJavascripts,
compileStylesheets,
compileLess,
compileStatic
);
const watch = gulp.parallel(
build,
watchJavascripts,
watchStylesheets,
watchStatic,
watchServer
);
export { build, watch };
export default watch;
/* eslint-enable */