简体   繁体   中英

Gruntjs copy subdirectories

I'm not sure on the right Gruntjs command for grunt-contrib-copy .

Initially, I had a directory with fonts in it and I needed to copy them all from the app/styles/fonts directory into a build/fonts directory so I used this:

{expand: true, flatten: true, src: ['app/styles/fonts/*'], dest: 'build/fonts'}

and it worked well.

I've now added a couple of sub-directories (inside app/styles/fonts ) with more font files in them but when I run the command it will copy the files and the folders but put the contents of the new directories into the build/fonts . I want them to remain in their respective folders.

How can I fix this?

{
 expand: true,
 flatten: true, //use only if you want to copy all files in destination folder without their respective folders
 src: ['app/styles/fonts/**'],
 dest: 'build/fonts'
}

try this it will copy all files and directories of fonts. but if you use faltten:true then it will copy all files into build/fonts and will break the directory structure.

So for keeping the same structure don't use flatten option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM