You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
865 B
TypeScript
24 lines
865 B
TypeScript
12 months ago
|
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<string>(JSON.parse(usedIconList.replace('export default ', '')))
|
||
|
|
||
|
const usedSvgIcons: string[] = arr.filter(i => i.startsWith(SvgPrefix))
|
||
|
|
||
|
await generateSvgJSON(usedSvgIcons.map(i => i.replace(`${SvgPrefix}:`, '')))
|
||
|
}
|