Skip to content

You can use this plugin to copy files in your Gatsby project. Specify absolute source path and relative destination path using plugin options.

Notifications You must be signed in to change notification settings

csath/gatsby-plugin-copy-files-enhanced

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gatsby-plugin-copy-files-enhanced npm npm

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-files

  • In gatsby-plugin-copy-files you should specify destination and you have no option to copy to multiple direcotries in one go. gatsby-plugin-copy-files-enhanced enables you to wildcard your destination, so that you can easily copy files.

  • This plugin has option to overwrite your destination direcotry simply using purge plugin option.

Plugin options

Option Description
source Absolute path of the source (eg: ${__dirname}/path)
destination Relative path to destination within public/ direcotry
You can add /*/ inside destination path to wildcard destination lookup
Refer to graphical explanation for better understanding
purge Overwrite destination. false by default

Important

This plugin should be used with gatsby-source-filesystem

Eample

{
    resolve: 'gatsby-plugin-copy-files-enhanced',
    options: {
        source: `${__dirname}/src/reportTemplate` ,
        destination: '/reports/*/',
        purge: true,
    }
}, {
    resolve: 'gatsby-plugin-copy-files-enhanced',
    options: {
        source: `${__dirname}/src/images` ,
        destination: '/containers/*/images',
        purge: false,
    }
}

Graphical explanation

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 public/reports/

Simply use this code to get this done
{
    resolve: 'gatsby-plugin-copy-files-enhanced',
    options: {
        source: `${__dirname}/src/template/` ,
        destination: '/reports/*/',
        purge: true,
    }
}

Inspired by gatsby-plugin-copy-files <3

About

You can use this plugin to copy files in your Gatsby project. Specify absolute source path and relative destination path using plugin options.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published