![](/img/trans.png)
[英]How to run a Grunt task after my Yeoman generator finishes installing?
[英]How to run a task after grunt watch finishes?
每次運行手表后,是否可以選擇運行特定任務? 例如
watch : {
js: {files:[], tasks:[]},
css: {files:[], tasks:[]},
}
我想在watch:js
和watch:css
之后都運行任務“ foo”,並且我不想將該任務添加到每個watch多任務任務列表中,並且我不想添加新的watch任務來自其他任務的所有文件都將被監視。
有手表的常規options.afterEach
api或其他東西嗎?
簡短答案 :否
Grunt或Grunt Watch沒有內置的方式。 這個github問題討論了添加下一個版本的可能性。
據我所知,有一個watch
事件,但是沒有什么象watch:start
或watch:end
一樣。 您可以像下面這樣使用此事件:
grunt.event.on('watch', function(action, filepath, target) {
grunt.log.writeln('Here is the action : ' + action);
grunt.log.writeln('Here is the filepath : ' + filepath);
});
不幸的是,這僅在開始時運行:
Running "watch" task
Waiting...
Here is the action : changed
Here is the filepath : pre/js/console.js
>> File "pre/js/console.js" changed.
Running "jshint:all" (jshint) task
...
相關問題:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.