{ isProd: true },
)
expect(content).toMatch(`_useCssVars(_ctx => ({
- "4003f1a6": (_ctx.color),
- "41b6490a": (_ctx.font.size)
+ "v4003f1a6": (_ctx.color),
+ "v41b6490a": (_ctx.font.size)
}))}`)
const { code } = compileStyle({
})
expect(code).toMatchInlineSnapshot(`
".foo {
- color: var(--4003f1a6);
- font-size: var(--41b6490a);
+ color: var(--v4003f1a6);
+ font-size: var(--v41b6490a);
}"
`)
})
isSSR = false,
): string {
if (isProd) {
- return hash(id + raw)
+ // hash must not start with a digit to comply with CSS custom property naming rules
+ return hash(id + raw).replace(/^\d/, r => `v${r}`)
} else {
// escape ASCII Punctuation & Symbols
// #7823 need to double-escape in SSR because the attributes are rendered