var gulp = require('gulp'),
sass = require('gulp-sass'),
watch = require('gulp-watch'),
browser = require('browser-sync'),
imagemin = require('gulp-imagemin');
var path = {
sass: 'sass/*.scss'
}
// 编译sass
gulp.task('sass', function(){
gulp.src(path.sass)
.pipe(sass())
.pipe(gulp.dest('css/'));
});
// 压缩图片
gulp.task('imagemin', function(){
gulp.src('./images/*.{png,jpg,gif,ico}')
.pipe(imagemin())
.pipe(gulp.dest('./img'));
});
// 自动刷新
var DEV = '.';
gulp.task('serve', function() {
browser.init({
server: DEV + '/'
});
gulp.watch(DEV + '/*.html' ).on('change', browser.reload)
gulp.watch(DEV + '/js/*.js').on('change', browser.reload)
gulp.watch(DEV + '/css/*.css').on('change', browser.reload)
});
gulp.task('watch', function(){
gulp.watch(path.sass, ['sass']);
});
gulp.task('default', ['watch', 'serve']);