forked from NCKUKIWI/CHUB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
43 lines (38 loc) · 1.1 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
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var sass = require('gulp-sass');
var nodemon = require('gulp-nodemon');
gulp.task('browser-sync', ['sass','nodemon'], function () {
browserSync.init(null, {
proxy: "http://localhost:3000",
port:7000
});
});
// Compile SASS檔案
gulp.task('sass', function() {
return gulp.src("assets/scss/*.scss")
.pipe(sass())
.pipe(gulp.dest("assets/css"))
.pipe(browserSync.stream());
});
//啟動server
gulp.task('nodemon', function (cb) {
var started = false;
return nodemon({
script: 'app.js'
}).on('start', function () {
if (!started) {
cb();
started = true;
}
});
});
//監看 檔案有改變時刷新或compile
gulp.task('watch', function () {
gulp.watch("app/scss/*.scss", ['sass']);
gulp.watch("assets/css/*.*").on('change', browserSync.reload);
gulp.watch("assets/js/*.*").on('change', browserSync.reload);
gulp.watch("views/*.*").on('change', browserSync.reload);
gulp.watch("views/**/*.*").on('change', browserSync.reload);
});
gulp.task('default', ['browser-sync', 'watch']);