Javascript 如何在Grunt Build中使用多个复制命令?
我想复制一些文件,运行其他任务,然后再次复制一些文件:Javascript 如何在Grunt Build中使用多个复制命令?,javascript,gruntjs,Javascript,Gruntjs,我想复制一些文件,运行其他任务,然后再次复制一些文件: copy:{....}, concat:{...}, copy:{...} 但是,当我运行grunt构建时,出现以下错误: SyntaxError: Duplicate data property in object literal not allowed in strict mode 当然,我明白,我不能在grunt json中多次使用同一属性(即“copy”)。但我的问题的解决方案是什么?如何在gruntfile.js的不同位置进行
copy:{....},
concat:{...},
copy:{...}
但是,当我运行grunt构建时,出现以下错误:
SyntaxError: Duplicate data property in object literal not allowed in strict mode
当然,我明白,我不能在grunt json中多次使用同一属性(即“copy”)。但我的问题的解决方案是什么?如何在gruntfile.js的不同位置进行复制
非常感谢 只需在所需子任务中拆分
副本注释:
copy: {
task1: {
files: [...]
}
task2: {
files: [...]
},
task3: {
files: [...]
}
}
然后像那样咕哝:
grunt.registerTask('development', [ 'copy:task1', 'concat', 'copy:task2' ]);
我也这样做。这是我的任务,就在Grunfile的末尾:
grunt.registerTask('client', [
'concat:app_js',
'concat:lib_js',
'uglify:app_lib_js',
'concat:client_js',
'concat:client_css',
'includes',
'concat:client_html',
'copy:client_gfx',
'copy:client_xml'
]);
这引用的是一个更高的结构,如下所示:
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: { ... concat jobs here ... },
// This is how to have multiple copy jobs
copy: {
client_gfx: {
// spec here
},
client_xml: {
// spec here
}
}
}
}