Reputation: 1748
I'm pretty new to grunt, so I need some help.
I ask this question on the official gruntjs/grunt-contrib-copy
but got no response.
I want to copy files using grunt-contrib-copy
from some dir to another and they look like this:
parentpath/ (source file)
/assets/sass/bootstrap/
/assets/sass/fontawesome/
/assets/sass/storms/
/assets/sass/wordpress/
/assets/sass/_layout.scss
/assets/sass/_woocommerce.scss
childpath/ (destiny file)
/assets/sass/bootstrap/
/assets/sass/fontawesome/
/assets/sass/storms/
/assets/sass/wordpress/
/assets/sass/_layout.scss
/assets/sass/_woocommerce.scss
My gruntfile is configure this way:
copy: {
parenttheme_bootstrap: {
src: '<%= dirs.parentpath %>/assets/sass/bootstrap',
dest: '<%= dirs.sass %>'
},
parenttheme_fontawesome: {
src: '<%= dirs.parentpath %>/assets/sass/fontawesome',
dest: '<%= dirs.sass %>'
},
parenttheme_storms: {
src: '<%= dirs.parentpath %>/assets/sass/storms',
dest: '<%= dirs.sass %>'
},
parenttheme_wordpress: {
src: '<%= dirs.parentpath %>/assets/sass/wordpress',
dest: '<%= dirs.sass %>'
},
parenttheme_partials: {
files: [{
expand: true,
cwd: '<%= dirs.parentpath %>/assets/sass/',
src: '_layout.scss',
dest: '<%= dirs.sass %>'
},
{
expand: true,
cwd: '<%= dirs.parentpath %>/assets/sass/',
src: '_woocommerce.scss',
dest: '<%= dirs.sass %>'
}]
}
}
// parent Task
grunt.registerTask( 'parent', [
'copy:parenttheme_bootstrap',
'copy:parenttheme_fontawesome',
'copy:parenttheme_storms',
'copy:parenttheme_wordpress',
'copy:parenttheme_partials',
'sass',
'postcss'
] );
When I run the parent task, the /assets/sass/bootstrap folder is correctly copied to his destiny. The same goes to the partial files.
But for some reason, all the other folders are not copied and I get no errors!
Running grunt parent --verbose I get this:
Running tasks: parent
Running "parent" task
Running "copy:parenttheme_bootstrap" (copy) task
Verifying property copy.parenttheme_bootstrap exists in config...OK
Files: ../../childpath/assets/sass/bootstrap -> ../assets/sass
Options: encoding="utf8", processContent=false, processContentExclude=[], timestamp=false, mode=false
Creating ../assets/sass
Created 1 directory
Running "copy:parenttheme_fontawesome" (copy) task
Verifying property copy.parenttheme_fontawesome exists in config...OK
Files: ../../childpath/assets/sass/fontawesome -> ../assets/sass
Options: encoding="utf8", processContent=false, processContentExclude=[], timestamp=false, mode=false
Creating ../assets/sass
Created 1 directory
Running "copy:parenttheme_storms" (copy) task
Verifying property copy.parenttheme_storms exists in config...OK
Files: ../../childpath/assets/sass/storms -> ../assets/sass
Options: encoding="utf8", processContent=false, processContentExclude=[], timestamp=false, mode=false
Creating ../assets/sass
Created 1 directory
Running "copy:parenttheme_wordpress" (copy) task
Verifying property copy.parenttheme_wordpress exists in config...OK
Files: ../../childpath/assets/sass/wordpress -> ../assets/sass
Options: encoding="utf8", processContent=false, processContentExclude=[], timestamp=false, mode=false
Creating ../assets/sass
Created 1 directory
Running "copy:parenttheme_partials" (copy) task
Verifying property copy.parenttheme_partials exists in config...OK
Files: ../../childpath/assets/sass/_layout.scss -> ../assets/sass/_layout.scss
Files: ../../childpath/assets/sass/_woocommerce.scss -> ../assets/sass/_woocommerce.scss
Options: encoding="utf8", processContent=false, processContentExclude=[], timestamp=false, mode=false
Copying ../../childpath/assets/sass/_layout.scss -> ../assets/sass/_layout.scss
Reading ../../childpath/assets/sass/_layout.scss...OK
Writing ../assets/sass/_layout.scss...OK
Copying ../../childpath/assets/sass/_woocommerce.scss -> ../assets/sass/_woocommerce.scss
Reading ../../childpath/assets/sass/_woocommerce.scss...OK
Writing ../assets/sass/_woocommerce.scss...OK
Copied 2 files
Anyone knows what I'm doing wrong here?
Thanks!
Upvotes: 1
Views: 42
Reputation: 1748
Thanks to @James suggestion, I make this work by changing to this:
sf2_bootstrap: {
files: [{
expand: true,
cwd: '<%= dirs.sfpath %>/assets/sass/bootstrap/',
src: '**/*.scss',
dest: '<%= dirs.sass %>/bootstrap/'
}]
},
Now my files are correctly copied.
James solution, copied all my files, but to the wrong directory, I don't know why.
Upvotes: 0
Reputation: 11931
I think you just need to experiment with your directory and file specs a little bit. A few things to try:
.../bootstrap/**/*.scss
.dest: '<%= dirs.sass %>/'
. It is possible that grunt is copying to a single file output, rather than a directory tree.A small example:
copy: {
parenttheme_bootstrap: {
src: '<%= dirs.parentpath %>/assets/sass/bootstrap/**/*.scss',
dest: '<%= dirs.sass %>/'
},
parenttheme_fontawesome: {
src: '<%= dirs.parentpath %>/assets/sass/fontawesome/**/*.scss',
dest: '<%= dirs.sass %>/'
},
Upvotes: 1