- browser-sync && sass
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
gulp.task('browser-sync',function(){
browserSync.init({
server: {
baseDir: './'
}
});
gulp.watch('scss/*.scss',['sass']);
gulp.watch('./*.html').on('change',browserSync.reload);
});
gulp.task('sass',function(){
return gulp.src('scss/*.scss')
.pipe(sass().on('error',sass.logError)) //解决sass出错程序终止问题
.pipe(gulp.dest('css'))
.pipe(browserSync.stream());
});
gulp.task('default',['browser-sync']);