grunt-contrib-watch 插件提供了很好的自动构建功能,但在某些情况下不显示来自任务的警告消息,这是我的 grunt.js:
min: {
app: {
src: [
'some.js',
],
dest: 'some.min.js'
},
}
watch: {
app: {
files: 'some.js',
tasks: ['min:app']
},
}
如果来源很好,一切顺利;但是当 UglifyJS 中止时:
直接运行 grunt min:app
Running "min:app" (min) task
Minifying with UglifyJS...ERROR
[L360:C46] Unexpected token name, expected punc (position: 8529)
<WARN> UglifyJS found errors. Use --force to continue. </WARN>
Aborted due to warnings.
通过 watch 插件自动构建
Waiting...OK
>> File "some.js" changed.
Running "min:app" (min) task
因此,如果不查看输出本身,就无法知道构建是否成功。
与 css less 类似的设置确实会向 CLI 显示错误,我想知道是否需要将某些内容传递给 grunt/watch plugin/uglify 以使其工作?