From 9f77df0bff2d1fd9d7f8216f7fca35a28ad08713 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Thu, 10 Mar 2022 17:24:32 +0530 Subject: [PATCH] Match regex only if declaration is a variable --- postcss/css-compile-variables.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/postcss/css-compile-variables.js b/postcss/css-compile-variables.js index cf2b451d..d5e78352 100644 --- a/postcss/css-compile-variables.js +++ b/postcss/css-compile-variables.js @@ -55,9 +55,11 @@ function resolveDerivedVariable(decl, {variables, derive}) { } function extractAlias(decl) { - const wholeVariable = decl.value.match(/var\(--(.+)\)/)?.[1]; - if (decl.prop.startsWith("--") && wholeVariable) { - aliasMap.set(decl.prop, wholeVariable); + if (decl.variable) { + const wholeVariable = decl.value.match(/var\(--(.+)\)/)?.[1]; + if (wholeVariable) { + aliasMap.set(decl.prop, wholeVariable); + } } }