我有以下 gulp 任务(最初来自此博客):
var path = {
MAIN_JSX: './myapp/app/jsx/main.js',
APP_DIR: 'myapp/app',
APP_JS: 'app.js',
};
gulp.task('watch', function() {
var watcher = watchify(browserify({
entries: [path.MAIN_JSX],
transform: [reactify],
debug: true,
cache: {}, packageCache: {}, fullPaths: true
}));
return watcher.on('update', function () {
watcher
.bundle()
.on('error', function(err) {
console.log(err.message)
this.end();
})
.pipe(source(path.APP_JS))
.pipe(gulp.dest(path.APP_DIR));
console.log('Updated on ' + (new Date().toString()));
})
.bundle()
.on('error', function(err) {
console.log(err.message)
this.end();
})
.pipe(source(path.APP_JS))
.pipe(gulp.dest(path.APP_DIR));
});
gulp.task('default', ['watch']);
该任务在我第一次发出 gulp 命令时运行;然后我第一次更新main.js
文件。之后它根本不运行。这里有什么问题?