Skip to content

Commit c6fa39b

Browse files
committed
fix(transformer): preserve suffix when variable name is entirely css/style(s)
Use a positive lookbehind assertion in the regex pattern to only remove the suffix if it's preceded by a word character. This prevents stripping suffixes from variables that consist entirely of these names.
1 parent 24fe89e commit c6fa39b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/rawstyle/src/transformer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const transform = (file: string, source: string): TransformResult => {
4545
rep = '""'
4646
} else {
4747
if (!activeVarName) return
48-
const clName = `${activeVarName.replace(/css|styles?$/i, '')}_${fileHash}`
48+
const clName = `${activeVarName.replace(/(?<=\w)(css|styles?$)/i, '')}_${fileHash}`
4949
css += `.${clName} {${cssTpl}}`
5050
rep = `'${clName}'`
5151
}

0 commit comments

Comments
 (0)