admin-vben/build/vite/plugin/svgSprite.ts

19 lines
532 B
TypeScript
Raw Normal View History

2023-03-18 13:10:54 +00:00
/**
* Vite Plugin for fast creating SVG sprites.
* https://github.com/anncwb/vite-plugin-svg-icons
*/
2023-07-29 10:46:43 +00:00
import path from 'node:path'
2023-03-18 13:10:54 +00:00
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
2023-07-29 10:46:43 +00:00
import type { PluginOption } from 'vite'
2023-03-18 13:10:54 +00:00
export function configSvgIconsPlugin(isBuild: boolean) {
const svgIconsPlugin = createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
svgoOptions: isBuild,
// default
2023-07-29 10:46:43 +00:00
symbolId: 'icon-[dir]-[name]',
2023-03-18 13:10:54 +00:00
})
2023-04-02 13:47:03 +00:00
return svgIconsPlugin as PluginOption
2023-03-18 13:10:54 +00:00
}