-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure svgo to inline styles with >=1 matches #54
Conversation
Thanks! Sounds good |
Interesting, at least in the svgr web interface, those settings seem to make it work |
I tested this with the bones image from the react-native-svg repo, but it does not seem to work, even if I enable SVGO. Let me know how I can help with this. |
@kristerkari This seems to be working now |
Thanks! I need to test it again. Btw. is it safe to enable SVGO for everyone? Does it have any known bugs? |
I haven't seen any bugs with this configuration, it's possible to give more aggressive options which can be buggy. But this set of options should only make more content compatible with react-native-svg, more specifically, any content with css style elements, having selectors which match more than a single element. This makes react-native-svg-transformer do essentially exactly the same thing as the new SvgCss component in react-native-svg, but at build time instead of runtime. |
The plain / default svgo configuration only inlines declarations from css rules where the selector matches exactly one element. Any selector which matches two or more element won't become inlined, and thus will render incorrectly in react-native-svg. |
Okay, sounds good! I'm going to include this in the next release. |
Thanks! Released in version 0.14.0 |
@msand It looks like this ended up being a breaking change after all. I noticed in my app that the default width/height of the SVG images not being applied anymore. |
Looks like that happens because Adding var defaultsvgrConfig = {
native: true,
plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
svgoConfig: {
plugins: [
{
inlineStyles: {
onlyMatchedOnce: false
}
},
{
removeViewBox: false
}
]
}
}; Should we add that @msand ? |
N.B not tested yet