Rollup plugin for creating SVG sprites, built on top of svg-baker and svg-baker-runtime, sharing the same foundation as webpack's svg-sprite-loader. Current stable version is 1.2.5, with TypeScript support. It supports both Rollup and Vite, and offers special handling for Vue 3 and React. Key differentiators include query-based imports (.svg?vueComponent, .svg?jsx), support for large numbers of SVGs via require.context, and minimal configuration. Release cadence is periodic with multiple patches. It integrates with Vue 3, React, and standard SVG usage.
npm install rollup-plugin-svg-spritesVerified import paths — ran on the pinned version, not inferred.
Minimal setup for Rollup with SVG sprite generation, showing both basic usage and Vue 3 component import.
Add @rollup/plugin-commonjs to plugins array before svgSprites.
Use import MyIcon from './icon.svg?vueComponent' instead of bare import.
Use import MyIcon from './icon.svg?jsx' instead of bare import.
Use href="#id" instead of xlink:href="#id" in SVG use elements.
Add declare module '*.svg?*' declarations in a .d.ts file.
npm install svg-baker
Add commonjs() plugin before svgSprites in rollup config.
Ensure svgSprites() is included and use correct import query for Vue/React.
Add type declarations as shown in README: declare module '*.svg?vueComponent' { ... }