Remove Style Element is an essential SVGO Plugin
See original GitHub issueFirst of all, thank you for this loader, it’s a great idea!
I want to load several SVG icons using this loaded, but it always removes the <style> Element of the SVG, which is not what I want. I need the <style> Element to stay in place as it contains icon-specific options. I tried to disable the corresponding SVGO plugin using
query: {
svgo: {
plugins: [
{ removeStyleElement: false },
]
}
}
But this has no effect. Digging deeper, I noticed that removeStyleElement
is a core plugin:
var essentialPlugins = ["removeDoctype", "removeComments", "removeStyleElement"];
It seems that I have no possibility to disable this plugin, is that correct? In this case, I could no longer use this project, which is quite sad. Is there really no option to disable removing the <style> element?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
SVGR (SVGO) removeAttrs does not remove specified fill ...
When I manually remove fill attribute from generated <Path> in icon component I am able to change the fill via props. .svgo.yml configuration:...
Read more >Options - SVGR
Keep width and height attributes from the root SVG tag. Removal is guaranteed if dimensions: false , unlike the removeDimensions: true SVGO plugin...
Read more >Can I clean up unused style attributes? - Beginners' Questions
Is there some way to remove all non-essential attributes, or specifically promote visual style properties to attributes, like fill/stroke?
Read more >svgo - npm
Plugin Description Default
removeDoctype remove doctype declaration enabled
removeXMLProcInst remove XML processing instructions enabled
removeComments remove comments enabled
Read more >@innocuous/svgo - npm Package Health Analysis | Snyk
What it can do ; removeOffCanvasPaths, removes elements that are drawn outside of the viewbox, disabled ; removeStyleElement, remove <style> elements, disabled.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If the SVGO version this loader uses is updated (see https://github.com/boopathi/react-svg-loader/issues/192), then you could use the new
inlineStyles
SVGO plugin (https://github.com/svg/svgo/blob/master/plugins/inlineStyles.js) to automatically convert everything in<style>
to inline attributes on the individual paths/etc. (essentially the same approach as saving the SVG with inline CSS in your editor, but done via this loader for you automatically).if you are using adobe illustrator, you can change the svg styling format to “inline-css” via change the Asset Export panel’s setting. And in sketch and Affinity Designer, it’s a default option of using “inline-css”