使用Grunt Bake观看多个文件,而无需一次编译

我想使用Grunt烘焙为我的咕噜工作stream程。 这是我的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'] } } }); 

我的问题:如果我改变一个文件, 所有的文件将被编译。 我可以通过为每个文件创build一个监听器来解决这个问题,但这似乎不是一个聪明的解决scheme:

 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文件…所以这不是我的select。 任何其他的解决scheme呢?

好的,我知道了!

有一个更新的任务完全是这样做的:

 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'] } } });