Skip to content

Commit e408cab

Browse files
committed
Copy 'important' on theme declaration values
1 parent ad74ed8 commit e408cab

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib/postcss-plugins.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ module.exports.extractThemeRulesPlugin = postcss.plugin('postcss-extract-theme-r
88
const prefix = options.prefix || THEME_VAR_PREFIX;
99

1010
return (root, results) => {
11+
/*
12+
ruleMap = {
13+
'.example': {
14+
color: 'theme-var(--color-primary);',
15+
'font-weight': 'theme-var(--font-weight-medium);'
16+
}
17+
}
18+
*/
1119
let ruleMap;
1220

1321
root.walkRules(rule => {
@@ -16,6 +24,12 @@ module.exports.extractThemeRulesPlugin = postcss.plugin('postcss-extract-theme-r
1624
ruleMap = ruleMap || (ruleMap = {});
1725
let declMap = ruleMap[rule.selector] || (ruleMap[rule.selector] = {});
1826

27+
let value = decl.value;
28+
29+
if (decl.important) {
30+
value += ' !important';
31+
}
32+
1933
declMap[decl.prop] = decl.value;
2034
decl.remove();
2135
}

0 commit comments

Comments
 (0)