Open vanchKong opened 1 year ago
https://github.com/vbenjs/vite-plugin-svg-icons/blob/7550357300793b96b3561fc708899b9f4309e906/packages/core/src/index.ts#L266
当 symbolId 需要设置成 [dir]-[name] ,且非嵌套目录的情况下
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];
https://github.com/vbenjs/vite-plugin-svg-icons/blob/7550357300793b96b3561fc708899b9f4309e906/packages/core/src/index.ts#L266
当
symbolId
需要设置成[dir]-[name]
,且非嵌套目录的情况下