-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
94 lines (81 loc) · 2.05 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
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
var exec = require("child_process").exec;
var gulp = require("gulp");
var browserSync = require("browser-sync").create();
var flatten = require("gulp-flatten");
var nodemon = require("gulp-nodemon");
gulp.task("browser-sync", function (cb) {
browserSync.init({
open: false,
proxy: "http://localhost:5000",
files: ["dist/**/*.*"],
port: 9000,
});
cb();
});
gulp.task("nodemon", function (cb) {
var started = false;
return nodemon({
script: "./server.js",
}).on("start", function () {
// to avoid nodemon being started multiple times
// thanks @matthisk
if (!started) {
cb();
started = true;
}
});
});
gulp.task("build", function (cb, a, b) {
exec("yarn hackmyresume:build hackmyresume:dist", function (
err,
stdout,
stderr
) {
if (err) {
console.error(`exec error: ${err}`);
return cb();
}
console.log(`stdout: ${stdout}`);
console.log(`stderr: ${stderr}`);
return cb();
});
});
gulp.task("watch-css", function (cb) {
// Avoid rebuilding everything for css changes !
gulp.watch(
["./src/**/*.css"],
{ usePolling: true },
gulp.series([
(done) => {
gulp.src("./src/**/html.css")
.pipe(flatten())
.pipe(gulp.dest("./dist/"))
.pipe(browserSync.stream());
done();
},
])
);
});
gulp.task("watch-tpl", function (cb) {
gulp.watch(
"src/**/*.{hbs,html,json}",
{ usePolling: true },
gulp.series([
(done) => {
console.log("Changes detected");
done();
},
"build",
(done) => {
browserSync.reload();
done();
},
])
);
});
gulp.task(
"default",
gulp.series(
gulp.parallel(["browser-sync", "nodemon", "watch-css", "watch-tpl"])
)
);