-
-
Notifications
You must be signed in to change notification settings - Fork 81
hashed file names #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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: |
Thank you and apologies for wasting your time. I missed that in the advanced section of the docs. |
It's all good. I know what it's like when you encounter a problem and just want to resolve it quickly. Hope you were able to set your project up correctly :) |
Please note this that these suggestions don't work for the css file. See sveltejs/template#39 |
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 //excerpt of rollup.js
export default {
input: 'src/index.js',
preserveEntrySignatures: false,
output: {
sourcemap: true,
format: 'es',
name: 'app',
dir: 'build',
entryFileNames: '[name]-[hash].js'
},
plugins: [
svelte({
// enable run-time checks when not in production
css: css => {
css.write(css.filename);
}
})
]
}; Also because I'm loading my css into a webcomponent, I parse the css filename by inspecting the module filename and swapping //index.js
let css_filename = import.meta.url.match(/[^\/]+\.js$/)[0].replace(/\.js$/,".css") See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import.meta for more info on this. |
CSS files will be hashed by default starting with 7.0 – see #136 |
I am not seeing this in action. CSS doesn't get hashed even with Rollup configured to output hashed JS files. Please provide details (Rollup config) on how this is supposed to work. |
First 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
The text was updated successfully, but these errors were encountered: