Vite plugin for fast creating SVG sprites. Generates an SVG sprite map from a directory of SVG files, supporting HMR, icon selection via DOM injection, and optional SVGO optimization. Current stable version 2.0.1, released under the MIT license. It is a maintained, Vite-specific alternative to svg-sprite-loader or webpack-based solutions, offering tight integration with Vite's dev server and build pipeline since v2.0.0.
npm install vite-plugin-svg-iconsVerified import paths — ran on the pinned version, not inferred.
Sets up the plugin to load SVG files from 'src/icons', configure symbol ID pattern, and enable SVGO optimization.
Update your Vite config to use the new option names: iconDirs, symbolId, etc.
Upgrade Vite to version 2.0.0 or later.
Add 'import 'virtual:svg-icons-register'' in your application's entry file (e.g., main.js/ts).
Use ES import syntax; ensure your project is configured for ESM.
Run 'npm install vite-plugin-svg-icons' and ensure the import statement is correct: 'import { vitePluginSvgIcons } from 'vite-plugin-svg-icons''.Upgrade Vite: 'npm install vite@latest'.
Ensure the plugin is added to the plugins array in vite.config.ts and that the import statement is at the top of your entry file.