vite-plugin-svg4vue weekly downloads statistics
By yisibell · npm · Vite plugins
A vite plugin which can transform svg icon to vue component, support optimization via SVGO, easy to customize svg color and size.
vite-plugin-svg4vue has 5,053 recorded weekly downloads on npm, an increase of 40.8% over the past 30 days, ranking #1526 of 3,247 tracked listings.
About vite-plugin-svg4vue
vite-plugin-svg4vue
A vite (5.x || 6.x || 7.x || 8.x) plugin which can transform SVG icon to vue (2.7.X || 3.x) component.
this plugin dependencies on
vue/compiler-sfc, so keep yourvueversion to 3.2.13+ or 2.7.14+.
Features
- SVGO optimization.
- Hot Module Replacement support.
- Support for
?url,?componentand?rawquery string. - Support custom svg icon (monochrome) color with
fill,fill-opacity,stroke,stroke-opacityattribute. - Support change svg icon size with
font-sizeand it will be responsive. - Support <a href="https://www.iconfont.cn/" target="_blank">Iconfont SVG Icons</a>.
Installation
# pnpm
$ pnpm add vite-plugin-svg4vue -D
# yarn
$ yarn add vite-plugin-svg4vue --dev
# npm
$ npm i vite-plugin-svg4vue -D
Development
The repository uses pnpm workspaces. The package is at the repository root and the Vue demo is the example workspace.
The root-level scripts are:
| Script | Description |
|---|---|
pnpm dev | Watch and rebuild the vite-plugin-svg4vue package with Rollup while developing the plugin. |
pnpm dev:example | Start the example Vite development server. |
pnpm build | Build the plugin package and generate JavaScript and TypeScript declaration files in lib/. |
pnpm build:example | Build the example app with Vite. This runs the production bundler only. |
pnpm build:all | Build the plugin, then run the example's complete build script, including type checking and the production build. |
pnpm lint | Check the root package with ESLint and eslint-plugin-format without changing files. |
pnpm lint:fix | Check and automatically format/fix the root package. |
pnpm --filter example lint | Check the example workspace with ESLint and eslint-plugin-format. |
pnpm --filter example lint:fix | Check and automatically format/fix the example workspace. |
pnpm release | Build the package, generate a changelog, publish it to npm, and push release tags. Use only when preparing a release. |
For example, run the demo in development mode from the repository root:
pnpm dev:example
This is equivalent to:
pnpm --filter example dev
You can also enter the workspace directory and run its scripts directly:
cd example
pnpm dev
pnpm build
To add a dependency to the demo, run this from the repository root:
pnpm --filter example add <package>
pnpm --filter example add -D <package>
Usage
Setup
// vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { svg4VuePlugin } from 'vite-plugin-svg4vue'
export default defineConfig({
plugins: [
vue(),
svg4VuePlugin(),
],
})
In Vue
<template>
<div>
<h2>SVG component: </h2>
<!-- you can change the svg icon color with `fill` attribute when it's a monochrome icon -->
<LogoSvg fill="red" />
<!-- you can change the svg icon size with `font-size` or `width`. both of this will be responsive -->
<LogoSvg font-size="48" />
<LogoSvg width="48" />
<h2>SVG url: </h2>
<p>
<img :src="logoSvgUrl" alt="" width="36" />
</p>
<h2>SVG raw: </h2>
<p>
<span v-html="logoSvgRaw"></span>
</p>
</div>
</template>
<script setup lang="ts">
import LogoSvg from '@/icons/logo.svg?component'
import logoSvgUrl from '@/icons/logo.svg?url'
import logoSvgRaw from '@/icons/logo.svg?raw'
</script>
Skip SVGO for a single file (Added in v2.8.1)
SVGO can be explicitly disabled for one file by adding the ?skipsvgo query string:
<template>
<div class="d-flex align-center mb-16">
<label class="mr-12"> ?component&skipsvgo: </label>
<PPTSvg />
</div>
<div class="d-flex align-center">
<label class="mr-12"> ?raw&skipsvgo: </label>
<span v-html="PPTSvgRaw"></span>
</div>
</template>
<script setup lang="ts">
import PPTSvg from '@/icons/ppt.svg?component&skipsvgo'
import PPTSvgRaw from '@/icons/ppt.svg?raw&skipsvgo'
</script>
Typescript
If you are using TypeScript, vite-plugin-svg4vue/client can be added to d.ts declaration file.
/// <reference types="vite-plugin-svg4vue/client" />
Options…
Description from the npm listing.
- vite
- vite-plugin
- vue
- svg
- svgo
- svg-component
- svg-icon
- icon
- vite-svg-loader
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (121)Similar npm Vite plugins plugins
All 20 vite-plugin-svg4vue alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/vite-plugin-svg4vue. First seen Dec 2, 2026; last successful collection Dec 6, 2026. See the methodology.