我想复制一些文件,运行其他任务,然后再次复制一些文件:
copy:{....},
concat:{...},
copy:{...}
然而,当我运行我的咕哝构建时,我得到了以下错误:
SyntaxError: Duplicate data property in object literal not allowed in strict mode
我当然理解,我不能在grunt json中多次使用相同的属性(即"副本")。但是解决我的问题的办法是什么?如何在gruntfile.js的不同位置进行复制?
非常感谢!
只需将copy
注释拆分到所需的子任务中即可:
copy: {
task1: {
files: [...]
}
task2: {
files: [...]
},
task3: {
files: [...]
}
}
然后像这样运行Grunt:
grunt.registerTask('development', [ 'copy:task1', 'concat', 'copy:task2' ]);
我也做同样的工作。这是我的任务,就在Gruntfile的末尾:
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
}
}
}
}