From 93d2daf573e5ca988d0c6778e73584ac099fbfde Mon Sep 17 00:00:00 2001 From: tonglx Date: Sat, 21 May 2022 09:03:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=201=E3=80=81=E5=85=BC=E5=AE=B9svgBuilder?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE=E8=B7=AF=E5=BE=84=E4=B8=BA=E5=8D=95?= =?UTF-8?q?=E4=B8=AA=E8=B7=AF=E5=BE=84=E6=88=96=E6=95=B0=E7=BB=84=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/svg/index.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/svg/index.ts b/build/svg/index.ts index 5e4ddcc..835ce56 100644 --- a/build/svg/index.ts +++ b/build/svg/index.ts @@ -1,6 +1,7 @@ import { Plugin } from "vite"; import { readFileSync, readdirSync, accessSync } from "fs"; import path from "path"; +import { isArray } from "lodash"; let idPerfix = ""; const svgTitle = /+].*?)>/; @@ -51,9 +52,10 @@ function findSvgFile(dir: string, uniqueNames: Record): string[ return svgRes; } -export const svgBuilder = (paths: string[], perfix = "icon"): Plugin | null => { - if (paths.length > 0) { +export const svgBuilder = (paths: string | string[], perfix = "icon"): Plugin | null => { + if (paths) { idPerfix = perfix; + paths = isArray(paths) ? paths : [paths]; const uniqueNames: Record = {}; const res = paths.reduce( (previousValue, currentValue) =>