[英]Watch multiple files with Grunt Bake without compiling all at once
我想在Grunt Bake的工作流程中使用Grunt Bake 。 這是我的grunt.js設置:
grunt.initConfig({
bake: {
build: {
files: {
'dev/foo.html': 'public/foo.html',
'dev/bar.html': 'public/bar.html',
'dev/foo2.html': 'public/foo2.html'
// ...
}
}
},
watch: {
bake: {
files: ['dev/*.html'],
tasks: ['bake:build']
}
}
});
我的問題:如果更改一個文件,則所有文件都會被編譯。 我可以通過為每個文件創建一個監視程序來解決此問題,但這似乎不是一個聰明的解決方案:
grunt.initConfig({
bake: {
foo: {
files: {
'dev/foo.html': 'public/foo.html'
}
},
bar: {
files: {
'dev/bar.html': 'public/bar.html'
}
},
foo2: {
files: {
'dev/foo2.html': 'public/foo2.html'
}
}
// ...
},
watch: {
foo1: {
files: ['dev/foo.html'],
tasks: ['bake:foo']
},
bar: {
files: ['dev/bar.html'],
tasks: ['bake:bar']
},
foo2: {
files: ['dev/foo2.html'],
tasks: ['bake:foo2']
}
}
});
想象有20多個不同的html文件...因此,這不是我的選擇。 還有其他解決方案嗎?
好的,我知道了!
確實有一個新的任務可以做到這一點:
grunt.initConfig({
bake: {
build: {
files: {
'dev/foo.html': 'public/foo.html',
'dev/bar.html': 'public/bar.html',
'dev/foo2.html': 'public/foo2.html'
// ...
}
}
},
watch: {
bake: {
files: ['dev/*.html'],
tasks: ['newer:bake:build']
}
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.