diff --git a/README.md b/README.md index b3cecad..37c793a 100644 --- a/README.md +++ b/README.md @@ -115,3 +115,23 @@ Stops Webpack from generating the .js.map files ]; } ``` + +### additionalFiles + +Default: [] + +Additional files to move to the asset directory. + +```javascript +// Your gatsby-config.js +{ + plugins: [ + { + resolve: "gatsby-plugin-asset-path", + options: { + additionalFiles: ['example.txt'], + }, + }, + ]; +} +``` diff --git a/src/gatsby-node.js b/src/gatsby-node.js index fbd635e..d65c03c 100644 --- a/src/gatsby-node.js +++ b/src/gatsby-node.js @@ -23,7 +23,7 @@ export const onCreateWebpackConfig = ( * Moves all js and css files into timestamp-named folder * @see {@link https://next.gatsbyjs.org/docs/node-apis/#onPostBuild} */ -export const onPostBuild = async ({ pathPrefix }) => { +export const onPostBuild = async ({ pathPrefix }, { additionalFiles = [] }) => { const publicFolder = "./public"; const assetFolder = path.join(publicFolder, `.${pathPrefix}`); @@ -48,6 +48,8 @@ export const onPostBuild = async ({ pathPrefix }) => { }), ); + await Promise.all(additionalFiles.map((file) => move(file))); + // Move statics data and icons await Promise.all(["static", "icons"].map(move));