-
Notifications
You must be signed in to change notification settings - Fork 19
/
gulpfile.babel.js
54 lines (46 loc) · 1.25 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
import fs from "fs";
import path from "path";
import { src, dest, watch, parallel, series } from "gulp";
import { exec } from "child_process";
import { create as browserSyncCreate } from "browser-sync";
import run from "gulp-run-command";
import concat from "gulp-concat";
import terser from "gulp-terser";
const browserSync = browserSyncCreate();
const path404 = path.join(__dirname, "website/404.html");
const content_404 = () =>
fs.existsSync(path404) ? fs.readFileSync(path404) : null;
const buildContent = () => exec("utils/build-gulp.sh");
const reload = (cb) => {
browserSync.init(
{
ui: {
port: 9002,
},
server: {
baseDir: "website/",
serveStaticOptions: {
extensions: ["html"],
},
},
files: "website/*.html",
port: 9001,
},
(_, bs) => {
bs.addMiddleware("*", (_, res) => {
res.write(content_404());
res.end();
});
}
);
cb();
};
const watchFiles = () => {
watch(["documentation/**"], { ignoreInitial: false }, buildAll);
};
const buildAll = series(buildContent);
const build = series(buildContent);
exports.build = build;
const deploy = series(build, parallel(watchFiles, reload));
exports.deploy = deploy;
exports.default = deploy;