-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
81 lines (73 loc) · 1.65 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
const rimraf = require("rimraf");
const postcss = require("gulp-postcss");
const gulp = require("gulp");
const posthtml = require("gulp-posthtml");
const connect = require("gulp-connect");
const rename = require("gulp-rename");
function buildCss() {
return gulp
.src("./src/**/*.scss")
.pipe(postcss())
.pipe(
rename(function (path) {
path.extname = ".css";
})
)
.pipe(gulp.dest("./dist"))
.pipe(connect.reload());
}
function buildHtml() {
return gulp
.src("./src/**/*.html", {
ignore: "./src/templates/**/*",
})
.pipe(posthtml())
.pipe(gulp.dest("./dist"))
.pipe(connect.reload());
}
function copyAssets() {
return gulp
.src("./assets/**/*")
.pipe(gulp.dest("./dist/assets"))
.pipe(connect.reload());
}
function copyJs() {
return gulp
.src("./src/**/*.js")
.pipe(gulp.dest("./dist"))
.pipe(connect.reload());
}
function cleanAll(cb) {
rimraf("./dist", cb);
}
function devServer() {
connect.server({
root: "./dist",
livereload: true,
});
gulp.watch(
["./src/**/*.html", "./src/**/*.scss", "./{tailwind,postcss}.config.js"],
{},
gulp.series(buildCss)
);
gulp.watch(
["./src/**/*.html", "./src/**/*.md", "./{posthtml,site}.config.js"],
{},
gulp.series(buildHtml)
);
gulp.watch(
["./src/**/*.js", "./{tailwind,postcss}.config.js"],
{},
gulp.series(copyJs)
);
gulp.watch(["./assets/*"], {}, copyAssets);
}
exports.serve = gulp.series(
cleanAll,
gulp.parallel(buildCss, buildHtml, copyJs, copyAssets),
devServer
);
exports.build = gulp.series(
cleanAll,
gulp.parallel(buildCss, buildHtml, copyJs, copyAssets)
);