Skip to content

Commit

Permalink
Merge pull request #15 from ehannes/optional-files-to-move
Browse files Browse the repository at this point in the history
Adds additionalFiles option
  • Loading branch information
chungryan authored Oct 7, 2019
2 parents 7cfc848 + 83d4446 commit 3d7194b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
},
},
];
}
```
4 changes: 3 additions & 1 deletion src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);

Expand All @@ -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));

Expand Down

0 comments on commit 3d7194b

Please sign in to comment.