我对 grunt 很陌生,所以我需要一些帮助。
我在官方上问过这个问题,gruntjs/grunt-contrib-copy
但没有得到回应。
我想使用grunt-contrib-copy
从某个目录复制文件到另一个目录,它们看起来像这样:
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
我的 gruntfile 是这样配置的:
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'
] );
当我运行父任务时, /assets/sass/bootstrap 文件夹被正确复制到他的命运中。部分文件也是如此。
但是由于某种原因,所有其他文件夹都没有被复制,我没有收到任何错误!
运行 grunt parent --verbose 我得到了这个:
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
任何人都知道我在这里做错了什么?
谢谢!