vbenjs / vite-plugin-svg-icons

Vite Plugin for fast creating SVG sprites.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

关于 symbolId 出现以 `-` 开头的情况

vanchKong opened this issue · comments

id = id.replace('--', '-')

symbolId 需要设置成 [dir]-[name] ,且非嵌套目录的情况下

[icon]-[dir]-[name] > [icon]--[name]
[dir]-[name] > -[name]
if (!dirName) {
    id = id.replace("--", "-");
    id = id.startsWith('-') ? id. substring(1) : id
}

直接在上面的判断后面加这个会更好点,考虑了不写 [dir]的情况,单独加个分隔符的入参更好

  id = id.startsWith('-') ? id. substring(1) : id
  id = id.replace(/\[name\]/g, fName).split('/').slice(-1)[0];