natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
990 stars 57 forks source link

[INFO] weird defs behaviour while using svgo optimization gradients #195

Closed salvaft closed 5 months ago

salvaft commented 5 months ago

What version of astro-icon are you using?

No response

Astro Info

Astro                    v4.2.5
Node                     v20.11.0
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         astro-icon

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Colors defined in defs like gradients not working properly

Looks like only the first one is considered. Related to: https://github.com/svg/svgo/issues/1896 and https://svgo.dev/docs/plugins/cleanup-ids/ image

What's the expected result?

defs should mantain svg style

Disabling some svgo plugins fixes the issue

export default defineConfig({
  integrations: [
  icon({
      svgoOptions: {
        plugins: [
          {
            name: "preset-default",
            params: {
              overrides: {
                cleanupIds: false,
              },
            },
          },
        ],
      },
    })
],
    },
  })],
});

image

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-xzukxg?file=src%2Fpages%2Findex.astro