【发布时间】:2020-09-17 14:13:45
【问题描述】:
我正在尝试将 index.html 文件复制到多个文件夹。我一直在寻找堆栈溢出,几乎找到了我正在寻找的解决方案。我的示例中的循环仅将 index.html 文件复制到文件夹数组的最后一个文件夹。我想知道我忽略了什么。有什么想法吗?
module.exports = function(grunt){
grunt.initConfig({
copy:{
files:{
flatten:true,
expand: false,
src: [
'scaffold/index.html',
],
dest: "dist/<%= grunt.option('folder') %>/",
filter: 'isFile',
force: true
}
}
})
function copytoFolders() {
var folders = ["300x600", "300x250", "336x280"], folder;
for (folder in folders)
{
grunt.option('folder', folders[folder]);
grunt.task.run('copy');
}
}
grunt.loadNpmTasks('grunt-contrib-copy-force');
grunt.registerTask('copyFol', copytoFolders)
}
【问题讨论】: