cascornelissen / svg-spritemap-webpack-plugin

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

Question: Need a way to add class or inline css to svg object #161

Closed grahlie closed 3 years ago

grahlie commented 3 years ago

Hello really like your plugin and saves a lot of time using this.

Have a small question that maybe is already possible but can't find anything regarding this in documentation.

Right now I'm using this plugin to generate a svg file that later on is included using:

<?php include_once('svg-sprite.svg'): ?>

When using this method the svg file is visbile in DOM and taking up space. I would like a way to make the svg add a class attribute to the svg root element or set inline style attribute to display hidden.

Again maybe there is a way to do this already but cant find it.

/Mathias

cascornelissen commented 3 years ago

This is not really supported by the plugin at the moment. Easiest is to just wrap that bit of inclusion code in a div yourself?

<div class="hidden">
    <?php include_once('svg-sprite.svg'); ?>
</div>
grahlie commented 3 years ago

This is not really supported by the plugin at the moment. Easiest is to just wrap that bit of inclusion code in a div yourself?

<div class="hidden">
    <?php include_once('svg-sprite.svg'); ?>
</div>

Thanks for your quick response!!

Yes this is what I have done right now, but thought this would be a simple improvement to pass an option like "wrapperClass" or something. But up to you.

Thanks again for a very nice plugin, cheers!