0.4.1 • Published 1 year ago

@remato/vite-plugin-svg-sprite v0.4.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

vite-plugin-svg-sprite

SVG sprite plugin for Vite

install

npm i @remato/vite-plugin-svg-sprite -D

Usage

vite.config.js:

import createSvgSpritePlugin from '@remato/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.id}`}
      />
    </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.4.1

1 year ago

0.4.0

1 year ago

0.3.6

1 year ago

0.3.5

1 year ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago