cascornelissen / svg-spritemap-webpack-plugin

SVG spritemap plugin for webpack
MIT License
210 stars 51 forks source link

Hashed spritemap file name in templates #125

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi, and thanks for a great plugin!

Since the spritemap.svg file name isn't hashed by default I ran into an issue where the browser didn't update it's cached version with a new file and some icons were missing from a UI.

I'd like to use spritemap.[hash].svg to avoid the above issue, but I haven't found a good way to include the hashed file name in a template, along the lines of <svg><use href="spritemap.[hash].svg#icon></use></svg>.

Some have suggested inlining the spritemap in the document, but I'd like to keep an external file and benefit from browser cache.

Please advise if the above is out of scope for this plugin, although it feels a common use case.

Thank you, Indrek

cascornelissen commented 4 years ago

There's not much this plugin can do in this case. It is meant to be used to generate a spritemap SVG and what you do with it after that is up to the developer as it totally depends on the rest of the stack that's in use. If you're setting up a simple HTML page you can use something like html-webpack-plugin, for some more advanced setups it would be possible to use stats-webpack-plugin which would output the generated assets to a JSON file which could be used in whatever back-end you have running.