Created
February 4, 2017 14:01
-
-
Save winwu/913a3315623ffa0a9ddb000b505114b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var watch = require('gulp-watch'); | |
var webpackStream = require('webpack-stream'); | |
var batch = require('gulp-batch'); | |
var compass = require('gulp-compass'); | |
var plumber = require('gulp-plumber'); | |
var clean = require('gulp-clean'); | |
var webpackConfig = require('./webpack.config.js'); | |
var browserSync = require('browser-sync'); | |
gulp.task('clean', function(){ | |
return gulp.src('./public/js/*') | |
.pipe(clean()); | |
}); | |
gulp.task('compass', function() { | |
gulp.src('./resources/assets/sass/**/*.scss') | |
.pipe(plumber({ | |
errorHandler: function (error) { | |
console.log(error.message); | |
this.emit('end'); | |
}})) | |
.pipe(compass({ | |
config_file: './resources/assets/config.rb', | |
css: './public/css', | |
sass: './resources/assets/sass' | |
})) | |
.on('error', function(error) { | |
console.log('compass error: ', error); | |
this.emit('end'); | |
}) | |
.pipe(gulp.dest('./public/css')) | |
.pipe(browserSync.stream()); | |
}); | |
gulp.task('webpack', function(callback) { | |
// webpack 配置文件 | |
gulp.src('./resources/assets/js/main.js') | |
.pipe(webpackStream(webpackConfig)) | |
.pipe(gulp.dest('./public/js')) | |
.pipe(browserSync.stream()); | |
}); | |
gulp.task('browser-sync', function(){ | |
browserSync.init({ | |
port: 3060, | |
open: false, | |
watchOptions: { debounceDelay: 1000 } | |
}); | |
gulp.watch(['./resources/assets/js/**/*'], ['webpack']); | |
gulp.watch('./resources/assets/sass/**/*.scss', ['compass']); | |
}); | |
gulp.task('default', ['clean', 'browser-sync', 'webpack', 'compass']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment