mirror of
https://github.com/cool-team-official/cool-admin-vue.git
synced 2024-11-01 14:10:27 +08:00
feat:
1、兼容svgBuilder的配置路径为单个路径或数组;
This commit is contained in:
parent
45f4750eb8
commit
93d2daf573
@ -1,6 +1,7 @@
|
|||||||
import { Plugin } from "vite";
|
import { Plugin } from "vite";
|
||||||
import { readFileSync, readdirSync, accessSync } from "fs";
|
import { readFileSync, readdirSync, accessSync } from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { isArray } from "lodash";
|
||||||
|
|
||||||
let idPerfix = "";
|
let idPerfix = "";
|
||||||
const svgTitle = /<svg([^>+].*?)>/;
|
const svgTitle = /<svg([^>+].*?)>/;
|
||||||
@ -51,9 +52,10 @@ function findSvgFile(dir: string, uniqueNames: Record<string, boolean>): string[
|
|||||||
return svgRes;
|
return svgRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const svgBuilder = (paths: string[], perfix = "icon"): Plugin | null => {
|
export const svgBuilder = (paths: string | string[], perfix = "icon"): Plugin | null => {
|
||||||
if (paths.length > 0) {
|
if (paths) {
|
||||||
idPerfix = perfix;
|
idPerfix = perfix;
|
||||||
|
paths = isArray(paths) ? paths : [paths];
|
||||||
const uniqueNames: Record<string, boolean> = {};
|
const uniqueNames: Record<string, boolean> = {};
|
||||||
const res = paths.reduce(
|
const res = paths.reduce(
|
||||||
(previousValue, currentValue) =>
|
(previousValue, currentValue) =>
|
||||||
|
Loading…
Reference in New Issue
Block a user