Skip to content

convertStyleToAttrs not enabled by default, or missing "(disabled by default)" in svgo --show-plugins #2154

Open
@qubodup

Description

@qubodup

Looking at svgo --show-plugins disabled plugins are marked as such.

$ svgo --show-plugins | grep tyle
 [ convertStyleToAttrs ] converts style to attributes
 [ inlineStyles ] inline styles (additional options)
 [ mergeStyles ] merge multiple style elements into one
 [ minifyStyles ] minifies styles and removes unused styles
 [ removeStyleElement ] removes <style> element (disabled by default)

It looks like convertStyleToAttrs is enabled by default, but it is not.

To Reproduce

  1. Prepare circle.svg:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" style="fill:red"/></svg>
  1. Run svgo circle.svg -o circleout1.svg, resulting in no change.

  2. create svgo.config.mjs:

export default {
  plugins: [
    {
      name: 'preset-default',
    },
    'convertStyleToAttrs'
  ],
};
  1. Run svgo circle.svg -o circleout2.svg, resulting in 0.112 KiB - 5.2% = 0.106 KiB and the following file:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="red"/></svg>

Expected behavior
convertStyleToAttrs should be enabled by default or
--show-plugins should state "(disabled by default)"

Screenshots
Image

Desktop:

  • SVGO Version 4.0.0
  • Node.js Version v22.16.0
  • OS: Windows 10 10.0.19045.5965

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssue is approved and contributors new to SVGO/OSS are especially encouraged to try to resolve it.help wantedIssue is approved and anyone is encouraged to resolve it in a new pull request.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions