-
Notifications
You must be signed in to change notification settings - Fork 34
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
After svgo 4.1.0, plugin options are being ignored. #125
Comments
+1 |
You need change {
name: 'removeViewBox',
// Disable a plugin by setting active to false.
active: false,
}, to {
removeViewBox: false,
}, |
@ademaro Ok, but why is it stated differently in the docs? Or is this just a workaround you found out? |
Maybe the docs are not UP-TO-DATE? |
Thanks @ademaro, that seems to work. |
I want to activate the plugin convertStyleToAttrs which is not part of the default presets. According to the svgo documentation at https://github.com/svg/svgo#configuration I have to do something like:
Unfortunately nothing is happening and the styles arent't converted to attributes. Does anyone have an idea on how to configure that? If I do it like @ademaro suggested the console tells me to:
I really think that this might be a bug. |
Hi! I've also had some hard time making it work, and I also thought it was a bug. But it actually does work as explained in the current documentation. The "full" flag param is key to have it work the way I would have expected. @ben-eb Maybe this param could be renamed to something so that would make its purpose clearer ? Like "finalPluginsList" or something like that ? For everyone having the same issue, here is a full explanation as I understand it. You have 3 main possibilities to define plugins options :
.pipe(svgmin({
// This is ignored if there is a svgo.config.files
plugins: [
// Will be added to the overrides of preset-default
{ removeViewBox: false },
{ cleanupAttrs: false },
// Everything below will be ignored if it is not an object AND/OR if it is NOT part of plugins included in the preset-default.
'removeXMLNS',
'removeDimensions',
]
}));
.pipe(svgmin({
// This is ignored if there is a svgo.config.files
full: true // This should be set so that the plugins list is passed directly to SVGO
plugins: [
// You can declare the preset-default, override some of its plugins settings, and then extend it with other built-in plugins
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false
}
}
},
// Everything below will be added and will extend the preset-default
'removeDimensions', // Activate a plugin just by mentioning it
// or add an object with name and params for the plugins if necessary
{
name: 'removeAttrs',
params: {
attrs: '(fill|stroke)'
}
},
]
})); |
Looks like we need to update the documentation, it was missed in #124. Happy to accept a pull request for that. 👍 |
@ben-eb Sure thing, I'll try and have a look and send you a PR |
After upgrading to [email protected], and with the provided example below, taken from the ReadMe, my svg viewbox is still getting removed:
The text was updated successfully, but these errors were encountered: