-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
41 lines (37 loc) · 1.04 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
const gulp = require("gulp")
const webpack = require("webpack")
const webpack_config = require("./webpack.config")
const sass = require("gulp-sass")
sass.compiler = require('node-sass')
const browser_sync = require("browser-sync").create()
browser_sync.init({ proxy: "localhost:3000" })
function build_js() {
return new Promise((resolve, reject) => {
webpack(webpack_config, (err, stats) => {
if (err) {
return reject(err)
}
if (stats.hasErrors()) {
return reject(new Error(stats.compilation.errors.join('\n')))
}
resolve()
})
})
}
function build_the_rest() {
return gulp.src("src/*.scss")
.pipe(sass().on('error', sass.logError))
.pipe(gulp.src(["src/*.html"]))
.pipe(gulp.dest("dist"))
}
function refresh_browser(cb) {
browser_sync.reload()
cb()
}
exports.default = () => {
gulp.watch(
"src/**",
{ ignoreInitial: false },
gulp.series(build_js, build_the_rest, refresh_browser)
)
}