You can use this plugin to copy files in your Gatsby project. Specify absolute
source path and relative
destination path using plugin options.
What's different from
gatsby-plugin-copy-filesyou should specify destination and you have no option to copy to multiple direcotries in one go.
gatsby-plugin-copy-files-enhancedenables you to wildcard your destination, so that you can easily copy files.
This plugin has option to overwrite your destination direcotry simply using
||Absolute path of the source (eg:
||Relative path to destination within
You can add
Refer to graphical explanation for better understanding
This plugin should be used with
resolve: 'gatsby-plugin-copy-files-enhanced'options:source: `/src/reportTemplate`destination: '/reports/*/'purge: trueresolve: 'gatsby-plugin-copy-files-enhanced'options:source: `/src/images`destination: '/containers/*/images'purge: false
Let's consider that you have a
template.js file that you need to copy to all reports within
public/reports/ direcotry and you are not sure of report names and how many would be there.
In such case you can wildcard the destination path so that you can easily copy
template.js to all direcotries with
Simply use this code to get this done
resolve: 'gatsby-plugin-copy-files-enhanced'options:source: `/src/template/`destination: '/reports/*/'purge: true