itmayziii / gatsby-plugin-no-javascript

Removes all javascript files created by Gatsby from the static HTML files.
MIT License
77 stars 13 forks source link

Delete unused Javascript Files in Public #6

Open marvinrabe opened 5 years ago

marvinrabe commented 5 years ago

Currently Gatsby still creates the javascript files in public even though they are unused.

It would be great if the plugin would make sure that they do not get created or it deletes them afterwards automatically.

itmayziii commented 5 years ago

@marvinrabe

This feature would need some more research to see if it is possible, I know we have access to change Gatsby's Webpack configuration through some of the APIs but I'm not sure what an implementation for this would look like right now.

itmayziii commented 5 years ago

Having looked into this a little more one solution would be to simply delete the files at the end of the build process using the onPostBuild node hook https://www.gatsbyjs.org/docs/node-apis/#onPostBuild.

Simply deleting the files after does not seem ideal though, it would be great if we could figure out a way to modify Gatsby's webpack configuration to never include these Gatsby scripts in the first place. This approach would also have the added benefit of being able to delete some of the code already written in this plugin such as implementations of onRenderBody and onPreRenderHTML SSR hooks.