vite-plugin-svgr icon indicating copy to clipboard operation
vite-plugin-svgr copied to clipboard

svg ID collision

Open dhasdiel opened this issue 9 months ago • 2 comments

When using Vite plugin svgr to import multiple SVG files into a single component, I got a collision of the style because the ids how to handle this?

dhasdiel avatar Nov 05 '23 11:11 dhasdiel

This should be fixed after:

  • installing @svgr/plugin-svgo
  • enabling SVGO in plugins options:
    {
      svgrOptions: {
        plugins: ['@svgr/plugin-svgo', '@svgr/plugin-jsx'],
      }
    }
    

However, when using single file multiple times, all components still use one single ID. This is known issue for inline svgs:

  • https://github.com/gregberge/svgr/issues/150
  • https://github.com/gregberge/svgr/issues/322

See: SVGR Docs > Options > SVGO

piotr-cz avatar Dec 06 '23 10:12 piotr-cz

My particular case may be fixed with https://github.com/laleksiunas/inline-svg-unique-id

piotr-cz avatar Dec 06 '23 11:12 piotr-cz