我在 Gruntfile 中使用 Grunt 复制任务。该项目由 Yeoman 创建。
我正在寻找有关如何简化任务定义的建议。您会注意到每组文件的 expand 和 dest 字段都是相同的。有没有办法可以简化这个?我可以使用选项吗?
这是我的任务
copy: {
componentsToTmp: {
files: [
{
expand: true,
cwd: '<%= yeoman.components %>/angular',
dest: '<%= yeoman.tmp %>/js',
src: ['angular.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/angular-bootstrap',
dest: '<%= yeoman.tmp %>/js',
src: ['ui-bootstrap-tpls.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/angular-cookies',
dest: '<%= yeoman.tmp %>/js',
src: ['angular-cookies.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/angular-l10n/build',
dest: '<%= yeoman.tmp %>/js',
src: ['l10n.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/angular-local-storage',
dest: '<%= yeoman.tmp %>/js',
src: ['angular-local-storage.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/angular-resource',
dest: '<%= yeoman.tmp %>/js',
src: ['angular-resource.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/angular-sanitize',
dest: '<%= yeoman.tmp %>/js',
src: ['angular-sanitize.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/angular-ui/build',
dest: '<%= yeoman.tmp %>/js',
src: ['angular-ui.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/angularjs-gravatardirective/src',
dest: '<%= yeoman.tmp %>/js',
src: ['md5-service.min.js', 'gravatar-directive.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/bootstrap/bootstrap/js',
dest: '<%= yeoman.tmp %>/js',
src: ['bootstrap.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/jquery',
dest: '<%= yeoman.tmp %>/js',
src: ['jquery.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/jquery-ui/ui/minified',
dest: '<%= yeoman.tmp %>/js',
src: ['jquery-ui.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/momentjs/min',
dest: '<%= yeoman.tmp %>/js',
src: ['moment.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/qrcode',
dest: '<%= yeoman.tmp %>/js',
src: ['qrcode.min.js']
},
{
expand: true,
cwd: '<%= yeoman.components %>/underscore',
dest: '<%= yeoman.tmp %>/js',
src: ['underscore-min.js']
},
{
expand: true,
cwd: '<%= yeoman.app %>/angular-local-storage-obscure',
dest: '<%= yeoman.tmp %>/js',
src: ['angular-local-storage-obscure.js']
}
]
}
}