forked from cotes2020/jekyll-theme-chirpy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
54 lines (52 loc) · 1.27 KB
/
gulpfile.js
File metadata and controls
54 lines (52 loc) · 1.27 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
const { exec } = require("child_process");
const browserSync = require("browser-sync").create();
const gulp = require("gulp");
// const concat = require('gulp-concat');
const gutil = require("gulp-util");
const siteRoot = "_site/wp2code-site";
function stoutJekyllLog(jekyll) {
const jekyllLogger = (buffer) => {
buffer = buffer.toString();
buffer = buffer.split(/\n/);
buffer.forEach(function (message) {
if (message != "") {
gutil.log("Jekyll: " + message);
}
});
};
jekyll.stdout.on("data", jekyllLogger);
jekyll.stderr.on("data", jekyllLogger);
}
function buildWeb() {
const jekyll = exec(
`bundle exec jekyll build --watch --force_polling -d ${siteRoot}`
);
stoutJekyllLog(jekyll);
}
function startWeb() {
browserSync.init({
files: [siteRoot + "/**"],
port: 1027,
open: false,
server: {
baseDir: siteRoot
}
});
}
function startWebWithJekyll() {
const jekyll = exec(
`bundle exec jekyll serve --livereload --force_polling -d ${siteRoot}`
);
stoutJekyllLog(jekyll);
}
gulp.task("jekyll", () => {
buildWeb();
});
gulp.task("run", () => {
startWebWithJekyll();
});
gulp.task("serve", () => {
startWeb();
});
gulp.task("build", gulp.parallel("jekyll", "serve"));
exports.default = startWebWithJekyll;