hashed file names
See original GitHub issueFirst time using rollup so excuse the ignorance. Is it possible to export bundle.js/.css with hashed names so the browser doesn’t serve cached versions when I push to production? How would this work updating public/index.html
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:7 (3 by maintainers)
Top Results From Across the Web
File Name Hashing: Creating a Hashed Directory Structure
File name hashing in the simplest terms can be defined as, creating a known and reproducible path, based on the name of the...
Read more >Adding Hashes to Filenames - SurviveJS
Webpack's placeholders allow you to shape filenames and enable you to include hashes to them. The most valuable placeholders are [name] , [contenthash]...
Read more >How to generate hashed file names of certificates
OpenSSL needs hashed file names of server certificates. The hashed file name consists of a hash obtained from OpenSSL, with a numerical extension...
Read more >Generate unique hash from filename - Stack Overflow
Generating a unique hash from a file's filename is fairly simple. However... It should only contain numbers, and I want it to be...
Read more >Dealing with hashed filenames - Davidsekar.com
Including hash value in filename helps the web browsers to identify the change in the file content or there by asset URL change,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For general support questions you’re better off asking on sites like stackoverflow.com. Github issues are for reporting bugs or feature requests etc.
About your question, please read the rollup docs:
I realised this is a closed issue. But it was the first one that appeared when googling, so I thought I drop a solution here for anyone who finds it useful (including future me…)
I found that the css object passed to the css function holds a hashed filename the same as your entry file, including the hash, but with the css extension.
So the below would output
index-[hash].js
andindex-[hash].css
Also because I’m loading my css into a webcomponent, I parse the css filename by inspecting the module filename and swapping
.js
for.css
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.meta for more info on this.