我使用Gulp来编写手写笔,但是任务似乎运行了两次,导致gulp-notify
行程。
这是我的gulpfile.js
var gulp, plugins;
gulp = require('gulp');
plugins = require('gulp-load-plugins')();
/**
* Watch for changes on stylus files, when detecting change run stylus task
* @return {void}
*/
gulp.task('watch-stylus', function() {
gulp.src('./app/Resources/stylus/**/*.styl')
.pipe(plugins.plumber())
.pipe(plugins.watch('./app/Resources/stylus/**/*.styl', {
verbose: true,
readDelay: 0
}))
.pipe(plugins.exec('gulp stylus'))
.pipe(plugins.notify("Stylus compiled"))
.pipe(plugins.plumber.stop());
});
/**
* Compile stylus and auto prefix the compiled css
* @return {void}
*/
gulp.task('stylus', function() {
gulp.src(['./app/Resources/stylus/**/*.styl', '!./app/Resources/stylus/**/_*.styl'])
.pipe(plugins.plumber())
.pipe(plugins.stylus())
.pipe(plugins.autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(plugins.plumber.stop())
.pipe(gulp.dest('web/css'));
});
我已检查的内容
我使用的插件
gulp-load-plugins
加载插件gulp-watch
要关注文件更改gulp-notify
通知手写笔已编译gulp-stylus
编译手写笔gulp-exec
即使编辑了部分gulp-autoprefixer
前缀为css gulp-plumber
因此gulp-watch
不会因错误而死亡