-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
47 lines (40 loc) · 1.01 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
var gulp = require('gulp');
var watch = gulp.watch;
var bs = require('browser-sync').create(); // create a browser sync instance.
var sass = require('gulp-sass');
function style(cb) {
return gulp.src("sass/*.scss")
.pipe(sass())
.on("error", sass.logError)
.pipe(gulp.dest("static/bookx/css"))
.pipe(bs.reload({stream: true}));
cb();
}
function browsersync() {
bs.init({
proxy: "localhost:8000",
open:false
})
}
function reload() {
bs.reload();
}
function watcher() {
browsersync();
watch("sass/**/*.scss").on('change', function(path, stats){
console.log(path);
style(reload);
})
// alternative - but neither actually reloads
// watch("sass/**/*.scss",
// {interval: 1000, usePolling: true},
// gulp.series(style, reload));
watch(["**/*.html"], function() {
bs.reload();
});
}
exports.style = style;
exports.watch = watcher;
gulp.task('default', function(){
watcher();
});