我遇到了问题gulp.我和... gulp-watch一起跑.一切都运行得很好.gulp-lessgulp-clean
当我编辑somefile.less并用分号丢失保存它或者我不小心留下尾随时;s,保存时我的代码中gulp-less有错误,在控制台中记录错误.我修复后gulp-watch继续观看文件,但gulp-less不会触发,也不会编译.当我gulp在终端再次停止并再次运行时,一切都恢复正常.
这是我的gulpfile.js:
var gulp = require('gulp');
var clean = require('gulp-clean');
var gutil = require('gulp-util');
var less = require('gulp-less');
var watch = require('gulp-watch');
var path = require('path');
gulp.task('clean', function() {
return gulp.src('src/main/webapp/styles/build', {read: false})
.pipe(clean().on('error', gutil.log))
});
gulp.task('less', function() {
return gulp.src(['src/main/webapp/styles/main.less'], {base: 'src/main/webapp/styles/'})
.pipe(less().on('error', gutil.log))
.pipe(gulp.dest('src/main/webapp/styles/build'))
.on('error', gutil.log);
});
gulp.task('watch', function() {
watch('src/main/webapp/styles/**/*.{less, css}', function() {
gulp.start('less')
.on('error', gutil.log); …Run Code Online (Sandbox Code Playgroud)