import { buildUtilsReadFile, buildUtilsWriteFile } from '../../utils' import { IconLog, SvgPrefix, iconBundlePath, iconListPath, iconSVGPath } from '../src' import { generateSvgJSON } from './icon-svg-json' export async function writeSvgJSONBundle() { const result = `import { addCollection } from '@iconify/vue' import CustomSvgJson from '/${iconSVGPath}'\n addCollection(CustomSvgJson);` IconLog('Svg Bundle', `Bundle svg icons from ${iconSVGPath}`) await buildUtilsWriteFile(iconBundlePath, result) } export async function rewriteSvgJSON() { const usedIconList = await buildUtilsReadFile(iconListPath) const arr = Array.from(JSON.parse(usedIconList.replace('export default ', ''))) const usedSvgIcons: string[] = arr.filter(i => i.startsWith(SvgPrefix)) await generateSvgJSON(usedSvgIcons.map(i => i.replace(`${SvgPrefix}:`, ''))) }