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';
|
2023-04-02 00:19:33 +08:00
|
|
|
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]',
|
|
|
|
});
|
2023-04-02 00:19:33 +08:00
|
|
|
return svgIconsPlugin as PluginOption;
|
2021-03-05 23:12:01 +08:00
|
|
|
}
|