Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upOption to disable versioning of main.js file? #1311
Comments
|
So, I found a way to disable the hashes using node.api.js. It's not pretty and it's rather brittle (especially that url-loader piece), so I would still like to see if perhaps an option could be provided with static.config.js. Here's the relevant piece of code within my app:
|
|
This would actually be the correct way to do this / via webpack options in the static config. We can turn this into a platform-feature if you'd like (where it would not set the hash in the webpack options). |
|
That would indeed be what I was after. The reason the above is brittle is because it depends on a lot of conditionals, which could grow out of date as react-static evolves. There are other webpack plugins besides url-loader that react-static aren't using today, but could in the future, which may contain a hash of some sort. But, as I said, for now what I have suffices. |
|
Thank you for providing it |
Is your feature request related to a problem? Please describe.
I am using react-static to create a site that is hosted out of S3. I want to be able to use object versioning to track changes to the objects over time, but I can't do that with the main JS file, as it has a hash code in the middle. I am guessing that this is used for cache busting, but S3 already has robust etag support built in, so its not as necessary for me. This also forces me to have extra logic to search for the old main JS file and remove it at deployment time, adding to the time it takes me to deploy my site
Describe the solution you'd like
I would like to disable the insertion of this hash into my main.js's filename, so that it comes out as "main.js" rather than "main.{hash}.js".
Describe alternatives you've considered
Currently, today, I have logic in my deployment script which manually searches for any file with the prefix "main.", and removes all that do not exist in my build directory. While this works, its not exactly a foolproof solution, and as said above it doesn't allow me to enable object versioning.
I could add a custom node.api.js script that renames this file myself after the build has completed, but this will require me to do a find/replace on the HTML files in order to fix all the references. I'll do it if necessary, but this would be a hack that might cause problems in the future.
I was digging through the code to see if I had missed something. It looks like the filename is generated by webpack-flush-chunks? If so, their docs don't mention anything about adding a hash to the filename, just "main.js" on its own. Perhaps there's an option there that I am missing? If there's a way to set options in the webpack config for this library, then that could be a suitable alternative, as I can easy add it to my node.api.js.