Reputation: 3963
I have this snipped in my 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/{,*/}*.*'
]
}
]
}
},
this copies all the files from the src:[...]
to the same folder in dist/. How can I achieve that some files get copied directly into the folder?
So for example instead of copying from /resources to "dist/resources", I want to copy to "dist/" directly.
EDIT: to make things clear:
I want all contents of "/resources" to be directly in "/dist". So for example if I have "resources/data/..", I want it to be "dist/data/.." Basically the internal folder/file structure in resources should be preserved, but the root should now be /dist instead of /resources
Upvotes: 0
Views: 482
Reputation: 11403
Use flatten: true, and specify two sets of files (one flattened, the other not).
Here:
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/{,*/}*.*'
]
}
]
}
},
You may also perform transformation on the final path of the file by implementing a custom rename function on your file objects.
More about flatten and rename here.
[UPDATE]
This below is what you describe in your update (change 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: [
'{,*/}*.*'
]
}
]
}
},
Upvotes: 1