A Rollup plugin that transforms SVG files into symbol strings, enabling custom sprite generation. Version 1.0.0 is the current stable release. It focuses solely on converting SVGs to `<symbol>` elements with optional SVGO optimization and custom ID extraction. Unlike broader SVG loading plugins, it outputs raw symbol markup for manual assembly into sprites. Minimal dependencies, easy to configure.
npm install rollup-plugin-svg-to-symbolVerified import paths — ran on the pinned version, not inferred.
Shows basic setup: configure Rollup plugin and import SVG as symbol string.
Provide extractId option with filePath to ensure uniqueness.
Set svgo to {} for default or { plugins: [] } to disable; avoid non-object values.Combine with rollup-plugin-copy or similar to output sprite files.
Place svgToSymbol() after other SVG-loading plugins but before any bundling.
Install svgo as a dev dependency: npm i svgo -D.