forked from Pelican-Elegant/elegant
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
58 lines (52 loc) · 1.23 KB
/
gulpfile.babel.js
File metadata and controls
58 lines (52 loc) · 1.23 KB
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
import fs from "fs";
import path from "path";
import { watch, parallel } from "gulp";
import { exec } from "child_process";
import { create as browserSyncCreate } from "browser-sync";
const browserSync = browserSyncCreate();
const content_404 = fs.readFileSync(
path.join(__dirname, "documentation/output/404.html")
);
const buildAll = () => exec("cd documentation && invoke build");
const reload = cb => {
browserSync.init(
{
ui: {
port: 9002
},
server: {
baseDir: "documentation/output",
serveStaticOptions: {
extensions: ["html"]
}
},
files: "documentation/output/*.html",
port: 9001
},
(_, bs) => {
bs.addMiddleware("*", (_, res) => {
res.write(content_404);
res.end();
});
}
);
cb();
};
const watchFiles = () => {
watch(
[
"documentation/content/**/*.md",
"documentation/content/**/*.rest",
"documentation/pelicanconf.py",
"documentation/publishconf.py",
"templates/**/*.html",
"static/**/*.css",
"static/**/*.js"
],
{ ignoreInitial: false },
buildAll
);
};
const elegant = parallel(watchFiles, reload);
exports.elegant = elegant;
exports.default = elegant;