sveltejs / svelte-loader

Webpack loader for svelte components.
MIT License
594 stars 73 forks source link

Non-deterministic css filename with emitCss #224

Open tsmigiel opened 1 year ago

tsmigiel commented 1 year ago

I use svelte-loader with emitCss: true and then MiniCssExtractPlugin in my webpack config. I also use svelte-spa-router with the wrap functionality to break my modules up into many chunks. And I use [contenthash] in my js and css filenames so they will get reloaded when changed.

I was investigating why every time I build all of my files end up with new hashes even for small changes. When I diffed the files of 2 different builds, where I made no changes between builds, the difference was the css filename generated by emitCss. Looking at the code here I see an "index++" and if I remove that in my build, then the generated files and hashes are the same.

I assume that index++ has some purpose, maybe to ensure generated files are unique. Could it be made deterministic? Or is it possible to reduce the cases where it is needed?

I noticed the "Help Wanted" issue, so if someone can explain why "index++" is needed, I don't mind trying to come up with a patch to address it.

Or is there some webpack config workaround I can do?