unplugin-svg-vue-component is a versatile utility that allows developers to import SVG files directly as functional Vue components, supporting both Vue 2.7 and Vue 3.x applications through a unified API. It leverages the `unplugin` architecture, enabling it to integrate seamlessly across various build tools like Vite. The current stable version, as of the provided metadata, is 0.1.1. Its release cadence follows a feature and bug-fix driven approach rather than a fixed schedule. A key differentiator is its dual Vue version compatibility and the optional integration with SVGO for robust SVG optimization, offering a consolidated solution compared to maintaining separate SVG loaders for different Vue versions or build environments.
npm install unplugin-svg-vue-componentVerified import paths — ran on the pinned version, not inferred.
Configures Vite with the plugin to import an SVG file as a typed Vue component, demonstrating setup for both configuration and in-component usage with optional optimization.
Add `"unplugin-svg-vue-component/client"` to the `types` array in your `tsconfig.json`.
Modify SVG imports in `.ts` or `<script setup lang="ts">` files to include `?component`.
Set `optimize: true` in the plugin options: `svgPlugin({ optimize: true })`.Verify that your `vite.config.js` (or equivalent) correctly imports `svgPlugin from 'unplugin-svg-vue-component/vite'` and registers it in the plugins array.
Add `"unplugin-svg-vue-component/client"` to `compilerOptions.types` in `tsconfig.json`, and ensure SVG imports use `?component` suffix (e.g., `import Icon from './my-icon.svg?component'`).
Double-check the relative path to your SVG file. Verify `unplugin-svg-vue-component` is installed (`npm i -D unplugin-svg-vue-component`) and correctly added to your `vite.config.js` `plugins` array.
No dependency data recorded yet.