I'd like to propose something like a .leave-these-files-alone file where we could specify files that shouldn't be put through the Gatsby build process other than copying
For example, I have a google webmaster tools verification file called blahblah.html and I want that to simply be copied from my pages directory into my public directory in the build process instead of it being converted to a folder named blahblah with an index.html file in it and I want to add a runprettify.js file to my pages directory and have it be simply copied upon build instead of Gatsby trying to process the file resulting in freakouts from window not being available.
I hope what I'm asking is making sense. I know with a lot of these things, doing things the React way solves the issue. But it would be nice to be able to add files or directories to the .leave-these-files-alone file and have those files/directories just copied instead of being processed.
Any thoughts from anyone are welcome. I plat to start implementing within the next few weeks.
Yeah — this is a decently common request. I think the best thing now is to just implement the postBuild hook and copy files over yourself — https://github.com/britt/britt.github.com/blob/0cdce436ced01eef9b7a6688a4c874afa63bc69a/gatsby-node.js#L99
In 1.0, with its plugin system, my plan is to add an officially supported plugin which will make this very simple e.g.
new DirectoryCopyPlugin({ // or whatever the name is we choose
directory: './directory-to-copy',
})
I'm also thinking there'll be an official "core theme" that is part of the official themes and others can build themes on top of (themes will be composable) and it could have this plugin installed by default.
How's that sound?
Also, what do you think a directory for these sort of files should be called?
That sounds great @kyleAMathews
I ended up adding a
&& cp pages/blah public/blah to the end of my build command in my package.json haha.
In regards to the name of such a directory, I think the name static would make sense. I know that everything is static after the build process but the static directory would be for files that don't change in any way and just get moved.
Thinking about this further @KyleAMathews , we may be complicating things. I'm thinking there should be a directory named 'static' in the root of the project that is served from /static in local development and then upon build gets copied to public/static.
That way any files in that directory would remain untouched and we wouldn't have to worry about side effects, etc.
Closed as this functionality is added to gatsby 1.0
Most helpful comment
Thinking about this further @KyleAMathews , we may be complicating things. I'm thinking there should be a directory named 'static' in the root of the project that is served from /static in local development and then upon build gets copied to public/static.
That way any files in that directory would remain untouched and we wouldn't have to worry about side effects, etc.