-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgulpfile.js
44 lines (40 loc) · 1.22 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
const exec = require("gulp-exec");
const gulp = require("gulp");
const newer = require("gulp-newer");
const purgecss = require("gulp-purgecss");
const purgeHtml = require("purgecss-from-html");
const build = "build";
const srcHtml = "src/public/index.html";
gulp.task("css", () =>
gulp.src("node_modules/bootstrap/dist/css/bootstrap.css")
.pipe(newer({
dest: build + "/bootstrap.css",
extra: [__filename, srcHtml]
}))
.pipe(purgecss({
content: [srcHtml],
defaultExtractor: purgeHtml,
safelist: {
standard: [
/show/, /modal-static/, /modal-backdrop/, // Bootstrap modal
// extractor can't figure dynamic class
"disabled",
"drag",
],
variables: [
/^--bs-btn-disabled/, // Fixes a bug of purgeCss
/^--bs-gray-(8|6)00/,
/^--bs-(danger|info)$/,
],
},
variables: true, // for Bootstrap
}))
.pipe(gulp.dest(build))
);
gulp.task("python", () =>
gulp.src("src/python/main.py")
.pipe(newer(build))
.pipe(exec(file => `pyminify ${file.path} --rename-globals --preserve-globals loadFont,processFont,main,processLegacy`, { pipeStdout: true }))
.pipe(gulp.dest(build))
);
gulp.task("default", gulp.parallel("css", "python"));