forked from AdvisorySG/dawn-advisory-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
98 lines (86 loc) · 2.4 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
95
96
97
98
const { series, parallel, watch, src, dest } = require("gulp");
const pump = require("pump");
const compiler = require("webpack");
const webpack = require("webpack-stream");
// gulp plugins and utils
const livereload = require("gulp-livereload");
const postcss = require("gulp-postcss");
const zip = require("gulp-zip");
// postcss plugins
const easyimport = require("postcss-easy-import");
const autoprefixer = require("autoprefixer");
const cssnano = require("cssnano");
const tailwindcss = require("tailwindcss");
function serve(done) {
livereload.listen();
done();
}
function handleError(done) {
return function (err) {
return done(err);
};
}
function hbs(done) {
pump(
[
src([
"*.hbs",
"partials/**/*.hbs",
"members/**/*.hbs",
"!node_modules/**/*.hbs",
]),
livereload(),
],
handleError(done),
);
}
function css(done) {
pump(
[
src("assets/css/screen.css", { sourcemaps: true }),
postcss([easyimport, tailwindcss, autoprefixer(), cssnano()]),
dest("assets/built/", { sourcemaps: "." }),
livereload(),
],
handleError(done),
);
}
function js(done) {
pump(
[
src("assets/js/main.js"),
webpack(require("./webpack.config.js"), compiler),
dest("assets/built/", { sourcemaps: "." }),
livereload(),
],
handleError(done),
);
}
function zipper(done) {
const filename = require("./package.json").name + ".zip";
pump(
[
src([
"**",
"!node_modules",
"!node_modules/**",
"!dist",
"!dist/**",
]),
zip(filename),
dest("dist/"),
],
handleError(done),
);
}
const HBS_PATHS = ["*.hbs", "partials/**/*.hbs", "members/**/*.hbs"];
const CSS_PATHS = ["assets/css/**/*.css"];
const JS_PATHS = ["assets/js/**/*.js"];
const hbsWatcher = () => watch(HBS_PATHS, hbs);
const cssWatcher = () => watch(CSS_PATHS.concat(HBS_PATHS), css);
const jsWatcher = () => watch(JS_PATHS, js);
const watcher = parallel(hbsWatcher, cssWatcher, jsWatcher);
const build = series(hbs, css, js);
exports.build = build;
exports.zip = series(build, zipper);
exports.default = series(build, serve, watcher);