Skip to content

Instantly share code, notes, and snippets.

@alphatr
Created May 7, 2015 10:47
Show Gist options
  • Save alphatr/8e614063ca3df506e429 to your computer and use it in GitHub Desktop.
Save alphatr/8e614063ca3df506e429 to your computer and use it in GitHub Desktop.
scss + gulp + browser-sync 开发,gulpfile 文件
'use strict';
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var plugins = require('gulp-load-plugins')();
var path = {
staticPath: './src/static',
viewPath: './src'
};
/* sass */
gulp.task('sass', function() {
return gulp.src(path.staticPath + '/sass/**/*.scss')
.pipe(plugins.sass({errLogToConsole: true}))
.pipe(plugins.autoprefixer())
.pipe(gulp.dest(path.staticPath + '/css'))
.pipe(reload({stream:true}));
});
/* browserSync */
gulp.task('browserSync', function () {
browserSync({
server: path.viewPath
});
gulp.watch(path.viewPath + "/*.html").on('change', reload);
});
/* default */
gulp.task('default', ['browserSync'], function(){
gulp.watch(path.staticPath + '/sass/**/*.scss', ['sass']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment