Skip to content

Commit bd83846

Browse files
committed
fix(vite.config): mdi icon convert camelCase to kebab-case
When the previous solution encounters mdiBattery80, it will be converted to mdi-battery-8-0. When using mdi-battery-80, an error that the icon cannot be found will be prompted. This solution first converts uppercase letters and then matches one or more numbers.
1 parent da3e65b commit bd83846

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

vite.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const mdi: Record<string, string> = {}
2020
Object.keys(mdicons).forEach((key) => {
2121
const value = (mdicons as Record<string, string>)[key]
2222
mdi[
23-
key.replace(
24-
/[A-Z]+(?![a-z])|[A-Z0-9]/g,
25-
($, ofs) => (ofs ? '-' : '') + $.toLowerCase(),
26-
)
23+
key
24+
.replace(/([A-Z])/g, '-$1')
25+
.toLowerCase()
26+
.replace(/([0-9]+)/g, '-$1')
2727
] = value
2828
})
2929

0 commit comments

Comments
 (0)