-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
59 lines (52 loc) · 1.54 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var concat = require('gulp-concat');
var nodemon = require('gulp-nodemon');
var sass = require('gulp-sass');
var wait = require('gulp-wait');
var reload = browserSync.reload;
gulp.task('default', ['watch'], function () {
});
gulp.task('browserSync', function() {
browserSync.init(null, {
proxy: "localhost:3000", // local node app address
port: 5000, // use *different* port than above
notify: true
});
});
gulp.task('nodemon', function(cb) {
var started = false;
return nodemon({
script: 'server.js',
ignore: [
'gulpfile.js',
'node_modules/'
]
}).on('start', function() {
if (!started) {
started = true;
cb();
}
}).on('restart', function() {
setTimeout(function() {
reload({ stream: false });
}, 1000);
});
});
gulp.task('sass', function() {
return gulp.src('assets/scss/*.scss')
.pipe(wait(500))
.pipe(sass({
includePaths: ['assets/scss']
}).on('error', sass.logError))
.pipe(concat('style.css'))
.pipe(gulp.dest('assets/css/'))
.pipe(browserSync.reload({
stream: true
}))
});
gulp.task('watch', ['browserSync', 'nodemon','sass'], function() {
gulp.watch('assets/scss/*.scss', ['sass']);
gulp.watch('*.html').on('change', reload);
gulp.watch('assets/js/*.js').on('change', reload);
});