Vite plugin to generate an SVG sprite from a set of SVG files and inject it into the HTML at build time or mount it in development via a virtual module. v1.8.1 is the current stable release, with active development and regular releases. It supports Vite >=5 and Node >=18. Key differentiators: file-based icon management, efficient HMR with cached compilation, SSR-friendly sprite injection, duplicate symbol detection, and virtual modules (register, ids, sprite). Compared to alternatives like vite-plugin-svg-icons, this is a modern fork with improved TypeScript types and a cleaner virtual module API. TypeScript ready.
npm install vite-plugin-svg-icons-ngVerified import paths — ran on the pinned version, not inferred.
Shows how to configure the Vite plugin with a custom symbol ID pattern and SVGO options, then import the virtual register module in the app entry.
Update imports to use slash-based paths: 'virtual:svg-icons/register', 'virtual:svg-icons/ids', 'virtual:svg-icons/sprite'.
If you relied on the previous default, set symbolId explicitly: symbolId: 'icon-[name]'.
Upgrade Vite to version 5 or later.
Use absolute paths for iconDirs when the icon directory is outside the current app root: iconDirs: [path.resolve(__dirname, '../../shared/icons')].
Add a declaration file (e.g., src/vite-env.d.ts) with: /// <reference types="vite-plugin-svg-icons-ng/client" />
Switch to ESM imports: import { createSvgIconsPlugin } from 'vite-plugin-svg-icons-ng'Use the new slash-based id: import 'virtual:svg-icons/register'