知道有点晚了,但这应该可以完成工作,像这样使用'grunt-contrib-copy'
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
copy: {
production: {
files: [{
expand: true,
cwd: "componentA/img/imgfolderA/",
src: ["*.*", "**/*.*"],
dest: "./assets/img/dirA/",
},
{
expand: true,
cwd: "componentB/img/imgfolderB/",
src: ["*.*", "**/*.*"],
dest: "./assets/img/dirB/",
},
]
}
}
});
// Production Build Tools
grunt.loadNpmTasks('grunt-contrib-copy');
// Default Production Build task(s).
grunt.registerTask('default', ['copy']);
};
ps 魔术在文件对象中,没有很好的文档记录,但是文档在这里,经过一两次阅读后,它是有道理的诚实!
grunt-contrib-copy 设置:https ://github.com/gruntjs/grunt-contrib-copy (底部的自述文件)
文件对象设置: http: //gruntjs.com/configuring-tasks#globbing-patterns
任务设置: http: //gruntjs.com/configuring-tasks