SpiriitLabs / vite-plugin-svg-spritemap

Vite plugin to generate svg spritemap
MIT License
47 stars 4 forks source link

Customize Symbol ID / add path name #27

Closed hackel closed 9 months ago

hackel commented 10 months ago

I am requesting a way to customize the generated symbol ID so that I can include the preceding path. I have the following directory structure:

icons/
    Add/
        Fill Circle.svg
    Alert/
        Fill Circle.svg

I want to be able to do e.g. <use xlink:href="__spritemap#sprite-Add/Fill%20Circle" />. Otherwise the sprite is full of duplicate symbol IDs and becomes useless. Thank you!

Applelo commented 10 months ago

Hi, I need to do some check if I can implement this easily. An alternative could be a svgo plugin but I don't know if it is possible to implement the behavior you want. So I can't promise anything in the near future about this but I keep an eye on.

[EDIT] Maybe we can add an idify option like the spritemap plugin for webpack to let you manage the id of the sprite dynamically?

solo-way commented 3 months ago

Hi. idify not helpful with @hackel scenario :( Only one svg with same name (but from different subfolder) included in spritemap.

Also, idify affects only symbol ids, but not use and view ids.

P.S.: Tested on windows.