🚀. Socket Launch Week Day 3:Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions.Learn more
Sign In

vite-plugin-svg-mix

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-svg-mix

Vite SVG Sprite 插件,不限制语言,React/Vue都可使用

latest
npmnpm
Version
0.3.1
Version published
Maintainers
1
Created
Source

Vite-Plugin-Svg-Mix

Vite SVG Sprite 插件,不限制语言,React/Vue都可使用

通过 svgo 进行优化,svg-parser调整结构,svg-sprite 进行生成

使用方法

  • 安装依赖
$ pnpm add vite-plugin-svg-mix -D
  • vite.config.ts 中的配置插件
import svgMix from 'vite-plugin-svg-mix'
import { resolve } from 'path'

export default () => {
  return {
    ...,
    plugins: [
      ...,
      svgMix({
        include: resolve(process.cwd(), 'src/assets/icons'),
        injectTo: 'body',
        prefix: 'icon',
      }),
    ],
  }
}
  • 代码中引用
<style>
  .icon {
    display: inline-block;
    width: 4em;
    height: 4em;
    stroke-width: 0;
    stroke: currentColor;
    fill: currentColor;
  }
</style>
<svg class="icon" viewBox="0 0 32 32">
  <use xlink:href="#icon-close"></use>
</svg>

Keywords

vite

FAQs

Package last updated on 25 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts