Skip to content

change_extendDefaultPlugins_to_preset_default - #12

Closed
luckyzeno wants to merge 1 commit into
danielstgt:masterfrom
luckyzeno:change_extendDefaultPlugins_to_preset_default
Closed

change_extendDefaultPlugins_to_preset_default#12
luckyzeno wants to merge 1 commit into
danielstgt:masterfrom
luckyzeno:change_extendDefaultPlugins_to_preset_default

Conversation

@luckyzeno

Copy link
Copy Markdown

"extendDefaultPlugins" utility is deprecated. So I changed it to preset_default plugin

@medeiroz

Copy link
Copy Markdown

Is there a timeline for when this will be merged?

@unre4l

unre4l commented May 5, 2022

Copy link
Copy Markdown

@danielstgt Hi can you review and merge this pr? Would appreciate it! 🙂

@georgehanson

Copy link
Copy Markdown

Until @danielstgt gets time to merge this in, I've created a fork which can be installed with NPM here @luckyzeno @medeiroz @unre4l

@tonila

tonila commented Jul 15, 2023

Copy link
Copy Markdown

I swithced to @georgehanson package.

Problem was svg were not scaling correcty and the reason was, that svgo was removing svg viewBoxes.
It seems, that svgo settings format has also changed.

I had to change svgoSettings from this:

.svgVue({
  ...
  svgoSettings: [
    { removeTitle: true },
    { removeViewBox: false },
    { removeDimensions: true }
  ]
});

to this

.svgVue({
  ...
  svgoSettings: {
    removeViewBox: false
  }
});

@tonila tonila left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems, option definitions are not working as expected.

Docs say, that removeViewBox and removeTitle are enabled by default and removeDimensions is not.

So to remove title and dimensions and preserve viewBox, configuration that worked for me was:

{
    loader: 'svgo-loader',
    options: {
        plugins: [
            {
                name: 'preset-default',
                params: {
                    overrides: {
                        removeViewBox: false
                    }
                },
            },
            'removeDimensions'
        ],
    }
}

It seems this is not possible to configure with current implemention. Or is it?

@danielstgt

Copy link
Copy Markdown
Owner

Hi @luckyzeno, and sorry for the very late reply on this, thanks a lot for taking the time to open the PR! 🙏

In the meantime this change has been implemented directly in master (commit 7810c9c): extendDefaultPlugins is now replaced by a preset-default + overrides setup in _buildSvgoPlugins.

To be transparent about why I'm closing this rather than merging it: the PR in its current form wouldn't have worked correctly. It passed svgoSettings straight into overrides, but svgoSettings is an array ([{ removeTitle: true }, …]) while overrides expects an object keyed by plugin name. On top of that, plugins that aren't part of preset-default (e.g. the default removeDimensions) would have been silently dropped. The current _buildSvgoPlugins implementation handles both cases and is covered by tests.

Closing as no longer needed, but really appreciate you flagging the deprecation, it's what got this fixed.

@danielstgt danielstgt closed this Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants