svgSprite.ts 532 B

12345678910111213141516171819
  1. /**
  2. * Vite Plugin for fast creating SVG sprites.
  3. * https://github.com/anncwb/vite-plugin-svg-icons
  4. */
  5. import path from 'node:path'
  6. import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
  7. import type { PluginOption } from 'vite'
  8. export function configSvgIconsPlugin(isBuild: boolean) {
  9. const svgIconsPlugin = createSvgIconsPlugin({
  10. iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
  11. svgoOptions: isBuild,
  12. // default
  13. symbolId: 'icon-[dir]-[name]',
  14. })
  15. return svgIconsPlugin as PluginOption
  16. }