【发布时间】:2017-01-21 17:28:46
【问题描述】:
突然间,我的 gulpfile.js 的所有翡翠文件的 watch 语句停止工作。你知道为什么吗?
翡翠任务:
gulp.task('jade', function() {
gulp.src('app/*.jade')
.pipe(jade())
.on('error', function(err) {
console.log(err)
this.emit('end')
})
.pipe(minifyHTML())
.pipe(gulp.dest('dist/'))
.pipe(browserSync.stream())
})
我也使用 BrowserSync,所以我把我所有的 watch 语句都放在了serve 任务中,看起来像这样:
gulp.task('serve', ['styles', 'html', 'jade', 'scripts'], function() {
browserSync.init({
server: './dist'
})
gulp.watch('app/css/**/*.sass', ['styles'])
gulp.watch('app/*.jade').on('change', function() {
gulp.run(['jade'])
browserSync.reload()
})
gulp.watch('app/src/*.js', ['scripts'])
})
另外,所有其他 watch 语句都有效,所以我真的不知道发生了什么。感谢您的帮助!
【问题讨论】:
-
我会尝试两件事。 1. 在
gulp.src('app/*.jade')前面添加return2. 将gulp.watch的jade更改为gulp.watch('app/*.jade', ['jade']).on('change', browserSync.reload())。我建议从jade升级到pug。 -
很高兴它对您有所帮助。我在下面写了我的答案。让我知道哪件事对您有帮助,还是您需要同时更改这两项?
-
我修改了这两个东西,现在完美运行
标签: javascript node.js gulp pug