-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (50 loc) · 1.39 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
const path = require("path");
const fs = require("fs-extra");
const gulp = require("gulp");
const sass = require("gulp-sass")(require("sass"));
const livereload = require("gulp-livereload");
const webserver = require("gulp-webserver");
const clean = require("gulp-clean");
const sassMatch = "src/scss/**/*.scss";
const htmlMatch = "src/index.html";
const jsMatch = "src/js/*.js";
const outBase = "dist";
function compileSass() {
return gulp
.src(sassMatch)
.pipe(sass().on("error", sass.logError))
.pipe(gulp.dest(path.join(outBase, "css")));
}
function html() {
return gulp.src(htmlMatch).pipe(gulp.dest(outBase));
}
function js() {
return gulp.src(jsMatch).pipe(gulp.dest(path.join(outBase, "js")));
}
function setup() {
return gulp.src("src/index.theme").pipe(gulp.dest(outBase));
}
function static() {
return fs.copy("src/static", outBase);
}
const build = gulp.series(setup, compileSass, html, js, static);
exports.build = build;
function server() {
gulp.src(outBase).pipe(webserver({ livereload: true }));
}
function watchFiles() {
gulp.watch("src/index.theme", setup);
gulp.watch(sassMatch, compileSass);
gulp.watch(htmlMatch, html);
gulp.watch(jsMatch, js);
gulp.watch("src/static", static);
}
const dev = gulp.series(
setup,
compileSass,
html,
js,
static,
gulp.parallel(server, watchFiles)
);
exports.dev = dev;