我的grunt-contrib-watch配置如下:
watch: {
tasks: ['copyFiles'],
js: {
files: [
path.join(__dirname, "../gscm-js/src/**/*.js"),
path.join(__dirname, "../gscm-js/templates/**/*.*")]
},
options: {
debounceDelay: 250,
}
}我的copyFiles任务看起来像这样;
grunt.registerTask('copyFiles', 'copy templates and js', function () {
console.log('in copyFiles');
var done = this.async();
var sourceScripts = path.join(__dirname, "../gscm-js/src");
var sourceTemplates = path.join(__dirname, "../gscm-js/templates");
ncp(sourceScripts, scriptsDirectory, function () {
ncp(sourceTemplates, templatesDirectory, done);
});
});BUt即使监视任务输出文件已更改,日志消息也不会输出到控制台。
发布于 2016-09-27 15:15:18
grunt-contrib-watch是一个Grunt多任务,而js是它的多个任务之一的名称。
您需要将tasks配置设置移动到js任务中:
watch: {
js: {
files: [
path.join(__dirname, "../gscm-js/src/**/*.js"),
path.join(__dirname, "../gscm-js/templates/**/*.*")
],
tasks: ['copyFiles']
},
options: {
debounceDelay: 250
}
}options可以保持原样--它得到了特殊对待,并在多个任务之间共享。
https://stackoverflow.com/questions/39717027
复制相似问题