我在我的gruntfile.js中剪了这个:
copy: {
dist: {
files: [
{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,txt}',
'.htaccess',
'images/{,*/}*.{webp,gif}',
'styles/fonts/{,*/}*.*',
'bower_components/sass-bootstrap/fonts/*.*',
'bower_components/components-font-awesome/{,*/}*.*',
'bower_components/ckeditor/**/*.*',
'resources/{,*/}*.*'
]
}
]
}
},
将所有文件从src:[...]
复制到dist /中的相同文件夹。如何实现某些文件直接复制到文件夹中?
因此,例如,我想直接复制到“dist /”,而不是从/ resources复制到“dist / resources”。
编辑:说清楚:
我希望“/ resources”的所有内容都直接在“/ dist”中。例如,如果我有“resources / data /..”,我希望它是“dist / data /..”基本上是内部文件夹/文件结构资源应该保留,但根目录应该是/ dist而不是/ resources
答案 0 :(得分:1)
使用flatten:true,并指定两组文件(一组扁平,另一组不整理)。
下面:
dist: {
files: [
// All these are going (as previously) to be copied along with their dir structure
{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,txt}',
'.htaccess',
'images/{,*/}*.{webp,gif}',
'styles/fonts/{,*/}*.*',
'bower_components/sass-bootstrap/fonts/*.*',
'bower_components/components-font-awesome/{,*/}*.*',
'bower_components/ckeditor/**/*.*',
]
},
// These will get flattened
{
expand: true,
dot: true,
flatten: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'resources/{,*/}*.*'
]
}
]
}
},
您还可以通过在文件对象上实现自定义重命名功能,对文件的最终路径执行转换。
有关展平和重命名here的更多信息。
[UPDATE]
以下是您在更新中描述的内容(更改cwd)。
dist: {
files: [
// All these are going (as previously) to be copied along with their dir structure
{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,txt}',
'.htaccess',
'images/{,*/}*.{webp,gif}',
'styles/fonts/{,*/}*.*',
'bower_components/sass-bootstrap/fonts/*.*',
'bower_components/components-font-awesome/{,*/}*.*',
'bower_components/ckeditor/**/*.*',
]
},
{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>/resources',
dest: '<%= yeoman.dist %>',
src: [
'{,*/}*.*'
]
}
]
}
},