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

19 lines
532 B
TypeScript
Raw Normal View History

2021-03-05 23:12:01 +08:00
/**
* Vite Plugin for fast creating SVG sprites.
* https://github.com/anncwb/vite-plugin-svg-icons
*/
2022-02-28 00:21:26 +08:00
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
2021-03-05 23:12:01 +08:00
import path from 'path';
import type { PluginOption } from 'vite';
2021-03-05 23:12:01 +08:00
export function configSvgIconsPlugin(isBuild: boolean) {
2022-02-28 00:21:26 +08:00
const svgIconsPlugin = createSvgIconsPlugin({
2021-03-05 23:12:01 +08:00
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
svgoOptions: isBuild,
// default
symbolId: 'icon-[dir]-[name]',
});
return svgIconsPlugin as PluginOption;
2021-03-05 23:12:01 +08:00
}