fix(sfc/style-vars): improve ignore style variable bindings in comments (#4202)
This commit is contained in:
@@ -12,8 +12,7 @@ import { PluginCreator } from 'postcss'
|
||||
import hash from 'hash-sum'
|
||||
|
||||
export const CSS_VARS_HELPER = `useCssVars`
|
||||
export const cssVarRE =
|
||||
/\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^)]*))\s*\)/g
|
||||
export const cssVarRE = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([^'"][^)]*))\s*\)/g
|
||||
|
||||
export function genCssVarsFromList(
|
||||
vars: string[],
|
||||
@@ -38,7 +37,7 @@ export function parseCssVars(sfc: SFCDescriptor): string[] {
|
||||
sfc.styles.forEach(style => {
|
||||
let match
|
||||
// ignore v-bind() in comments /* ... */
|
||||
const content = style.content.replace(/\/\*[\s\S]*\*\//g, '')
|
||||
const content = style.content.replace(/\/\*([\s\S]*?)\*\//g, '')
|
||||
while ((match = cssVarRE.exec(content))) {
|
||||
const variable = match[1] || match[2] || match[3]
|
||||
if (!vars.includes(variable)) {
|
||||
|
||||
Reference in New Issue
Block a user