import process from 'node:process'; import path from 'node:path'; import type { PluginOption } from 'vite'; import Icons from 'unplugin-icons/vite'; import IconsResolver from 'unplugin-icons/resolver'; import Components from 'unplugin-vue-components/vite'; import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'; import { FileSystemIconLoader } from 'unplugin-icons/loaders'; import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'; export function setupUnplugin(viteEnv: Env.ImportMeta) { const { VITE_ICON_PREFIX, VITE_ICON_LOCAL_PREFIX } = viteEnv; const localIconPath = path.join(process.cwd(), 'src/assets/svg-icon'); /** The name of the local icon collection */ const collectionName = VITE_ICON_LOCAL_PREFIX.replace(`${VITE_ICON_PREFIX}-`, ''); const plugins: PluginOption[] = [ Icons({ compiler: 'vue3', customCollections: { [collectionName]: FileSystemIconLoader(localIconPath, svg => svg.replace(/^