-
-
Notifications
You must be signed in to change notification settings - Fork 416
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
Is there a way to pass custom config/plugins to svgo? #52
Comments
@marcofugaro it is only possible using |
how do you use the |
You can deduce how to do it in the same script : https://github.com/smooth-code/svgr/blob/master/src/index.js#L52 |
so a thing like this will work? {
loader: 'svgr/webpack',
options: {
svgo: {
pretty: true,
multipass: true,
plugins: [
{ sortAttrs: true },
{ removeDimensions: true },
{ removeStyleElement: true },
{ convertColors: { currentColor: true } },
{ removeAttrs: { attrs: '(xmlns.*)' } },
],
},
semi: false,
singleQuote: true,
trailingComma: 'es5',
icon: true,
},
}, |
You should be more explicit in the readme |
@marcofugaro If you are using |
thank you! |
Why not move to a plugin architecture? There could be a package for whatever transformation the user wants ( |
@wtgtybhertgeghgtwtg yes it is an idea! |
What about a way to straight up disable SVGO? There's a bug causing viewBox to be removed in cases where it's unsafe. |
You can already disable svgo using |
I tried that but it didn't have an effect, but I'm also using gatsby-plugin-svgr because I'm using Gatsby and it doesn't really give you another way to use webpack. So effectively I passed |
This is a pretty critical feature IMO. I also tried chaining the SVGO loader in Webpack and it didn't work. Is there a reason this is difficult to implement? Surely it should just be passing a configurable object to |
I have added a pull request with the config option name |
@neoziro what do you think about pulling out all configs and just using the ones in the projects root? E.g. if there's a prettier config, svgo config, etc, use it. |
@lifeiscontent yes I think it is a good move, but have to support both |
When will this changes released? @neoziro |
@bobysf12 I don't have a release date, sorry. |
v2 is published 🎉 |
🎉 So does this work with v2 @neoziro? {
loader: 'svgr/webpack',
options: {
svgo: {
pretty: true,
multipass: true,
plugins: [
{ sortAttrs: true },
{ removeDimensions: true },
{ removeStyleElement: true },
{ convertColors: { currentColor: true } },
{ removeAttrs: { attrs: '(xmlns.*)' } },
],
},
},
}, |
Replace |
Thank you! You're the man! |
Good job with v2, the new api and options look dope as hell! I used the {
loader: '@svgr/webpack',
options: {
svgAttributes: {
fill: 'currentColor',
},
svgoConfig: {
multipass: true,
pretty: process.env.NODE_ENV === 'development',
indent: 2,
plugins: [
{ sortAttrs: true },
{ removeViewBox: false },
{ removeDimensions: true },
{ convertColors: { currentColor: true } },
],
},
},
}, |
Judging from the readme, you can only enable/disable svgo and some of its plugin, but I wanted to use some other svgo plugins.
Does the svgo parameter in node work also as a config object? It's not clear in the readme.
The svgo plugins I wanted to use are
removeStyleElement
,convertColors: { currentColor: true }
, or theinlineStyles
plugin.The text was updated successfully, but these errors were encountered: