How to use Gulp to copy a directory and all of its contents
When building a site or app with Gulp, you often simply need to copy a folder and all of its contents recursively.
Doing it simply is tricky, unless you know this simple incantation:
- put a
*
after the folder name (myfolder*
) - follow that with a
/**/*
for recursive copy - total string is
myfolder*/**/*
- all done
Example
1 | // recursively copy 'css', 'imgs', and 'fonts' to `dist` directory: |
The results, displayed here using tree command (another nifty tool):
1 | dist |