0.0.2 • Published 2 years ago

@alexfromearth/vite-plugin-svg-sprite v0.0.2

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

vite-plugin-svg-sprite

Fork of https://github.com/meowtec/vite-plugin-svg-sprite, adds ability to pass a function to symbolId SVG sprite plugin for Vite

install

npm i vite-plugin-svg-sprite -D

Usage

vite.config.js:

import createSvgSpritePlugin from 'vite-plugin-svg-sprite';

const config = {
  plugins: [
    createSvgSpritePlugin({
      symbolId: 'icon-[name]-[hash]',
    }),
  ],
}

app code:

import appIconId from './path/to/icons/app.svg';

// react or vue component, as you want
export default function App() {
  return (
    <svg>
      <use
        xlinkHref={`#${appIconId}`}
      />
    </svg>
  );
}

options

const plugin = createSvgSpritePlugin(options);

options.symbolId: string

For generating the id attribute of <symbol> element. Defaults to [name]

options.include: string | string[]

Match files that will be transformed. Defaults to '**.svg'. See micromatch for the syntax document.

options.svgo: boolean | SvgoOptions

Enable SVGO for optimizing SVG. Defaults to true.

0.0.2

2 years ago

0.0.1

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago