cascornelissen / svg-spritemap-webpack-plugin

SVG spritemap plugin for webpack
MIT License
207 stars 49 forks source link

Provide option to add custom attributes to SVG element. #182

Closed jgerigmeyer closed 2 years ago

jgerigmeyer commented 2 years ago

First off, thanks for this plugin!

I'm aware that this is essentially a duplicate of #161. Would you consider a PR that adds an option for a custom class on the SVG element? It seems like that would be a simple change (as opposed to allowing arbitrary attributes), and would allow for easy styling (often display: none;) via CSS without the need for an additional wrapper each place the SVG is used.

If you're open to it, I'm happy to submit a PR.

Thanks!

cascornelissen commented 2 years ago

I'm open to a PR for sure but IMO it should be a setup that supports passing any attribute. If we don't do it like that, someone will prefer to use id for this and they will create a ticket, then someone wants to add a title or inline styles and so on.

So something like being able to pass an object (keys being attribute names and values being their value) to output.svg.attributes would work for me.

jgerigmeyer commented 2 years ago

@cascornelissen That makes sense. PR adjusted to allow arbitrary attributes. ✅