Vite plugin (v1.0.4) for importing SVG files as Svelte components, URLs, or raw strings, inspired by React's @svgr/webpack. Ships TypeScript types. Differentiators: optional SVGO processing, per-directory type configuration via include/exclude, and query parameter overrides (?component, ?url, ?raw). Alternatives: iconify for icon sets. Released sporadically; peer deps svelte >=3.x and vite >=2.9.13. Stable for basic usage, but limited community adoption.
npm install vite-plugin-svelte-svgrVerified import paths — ran on the pinned version, not inferred.
Configures vite-plugin-svelte-svgr in SvelteKit (v1.0.0-next.346+) and imports SVG as a Svelte component.
Move plugin config to svelte.config.js under kit.vite.plugins array.
Use relative paths like 'src/lib/icons' or globs like 'src/**/*.svg'.
Configure SVGO to preserve viewBox: { svgo: { plugins: [{ name: 'preset-default', params: { overrides: { removeViewBox: false } } }] } }.Pin exact version and test upgrades carefully.
Run `npm install vite-plugin-svelte-svgr -D`
Use `import svgr from 'vite-plugin-svelte-svgr'` instead of `import { svgr } from ...`Ensure `"type": "module"` in package.json or use .mjs extension for config.