Skip to content
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

"cleanupIDs: false" still removes ID attributes from SVG nodes #46

Closed
kettanaito opened this issue Jun 10, 2020 · 1 comment
Closed

Comments

@kettanaito
Copy link

Hey! Thank you for the awesome plugin. While using it, I've discovered what appears to be an unexpected behavior. I'd like to know your opinion on this.

Current behavior

Setting svgoConfig.cleanupIDs: false still removes id attributes from SVG nodes.

Expected behavior

Setting svgoConfig.cleanupIDs: false does not remove id attributes from SVG nodes.

Steps to reproduce

// gatsby-config.js
module.exports = {
  plugins: [
     {
      resolve: `gatsby-plugin-svgr`,
      options: {
        svgoConfig: {
          cleanupIDs: false,
        },
      },
    },
  ]
}
// example.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" focusable="false">
  <title>
    Gatsby
  </title>
  <circle cx="14" cy="14" r="14" fill="#639"/>
  <path id="i-should-persist" fill="#fff" d="M6.2 21.8C4.1 19.7 3 16.9 3 14.2L13.9 25c-2.8-.1-5.6-1.1-7.7-3.2zm10.2 2.9L3.3 11.6C4.4 6.7 8.8 3 14 3c3.7 0 6.9 1.8 8.9 4.5l-1.5 1.3C19.7 6.5 17 5 14 5c-3.9 0-7.2 2.5-8.5 6L17 22.5c2.9-1 5.1-3.5 5.8-6.5H18v-2h7c0 5.2-3.7 9.6-8.6 10.7z"/>
</svg>

In the compiled example.svg there is no `id="i-should-persist".

@zabute
Copy link
Owner

zabute commented Jul 16, 2020

You should nest svgo config under the plugins key. See example config in readme. Ref: #38 & #40.

@zabute zabute closed this as completed Jul 16, 2020
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

No branches or pull requests

2 participants