我想在工作流程中使用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文件...因此,这不是我的选择。还有其他解决方案吗?
最佳答案
好的,我知道了!
确实有一个newer task可以做到这一点:
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']
}
}
});
关于javascript - 使用Grunt Bake观看多个文件,而无需一次编译所有文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22101100/