npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@manzhixing/vite-plugin-svg-sprite-gen

v1.0.1

Published

SVG Sprite Generator for Vite

Downloads

26

Readme

vite-plugin-svg-sprite-gen

SVG Sprite Generator for Vite

Install

npm install vite-plugin-svg-sprite-gen -D

# OR

yarn add vite-plugin-svg-sprite-gen -D

# OR

pnpm add vite-plugin-svg-sprite-gen -D

Usage

基础用法

  1. vite.config.ts 中引入插件
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import SVGSpriteGen from 'vite-plugin-svg-sprite-gen'

export default defineConfig({
    plugins: [vue(), SvgSpriteGen()]
})
  1. main.ts 中引入虚拟模块
import 'virtual:svg-sprite-gen'
  1. .vue 文件中使用
<template>
    <svg>
        <use xlink:href="#home" href="#home"></use>
    </svg>  
</template>

配置选项

// ...
import SVGSpriteGen from 'vite-plugin-svg-sprite-gen'

export default defineConfig({
    plugins: [vue(), SvgSpriteGen({
        // 配置选项
    })]
})
  1. include

    需要生成 SVG 精灵的文件路径列表

    类型: string[]
    默认值: ['**/*.svg']

  2. exclude

    不需要生成 SVG 精灵的文件路径列表

    类型: string[]
    默认值: ['**/node_modules/**', '**/dist/**']

  3. svgoConf

    SVGO 配置,可以是一个布尔值或 SVGO 配置对象

    类型: boolean | Config
    默认值: true
    说明: 如果为 true,可以在项目根目录下创建一个 svgo.config.js 文件,然后导出一个 SVGO 配置对象

  4. symbolId

    SVG 精灵中每个图标的 ID 前缀

    类型: string
    默认值: [name]
    说明: 必须包含 [name] 这个占位符,它将被替换为实际的文件名或图标名称,用于动态生成唯一的 ID。
    示例: 文件为 home.vue 配置为 icon-[name],那么生成的id为icon-home

  5. output

    SVG 精灵文件的输出路径

    类型: string
    默认值: sprite.svg

  6. mode

    SVG 精灵的加载方式,可以是 'virtual' 或 'inline'

    类型: 'virtual' | 'inline'
    默认值: 'virtual' 说明: inline 模式下,会在 HTML 文件中注入 SVG 精灵,无需引入虚拟模块直接使用

License

MIT