@db-ux/core-postcss-plugin 4.5.4-postcss-a42fe67 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -70,7 +70,10 @@ export const transformRoot = (root, staticVarMap, referencedVars, propertyNames,
|
|
|
70
70
|
});
|
|
71
71
|
if (removeAtProperty) {
|
|
72
72
|
root.walkAtRules('property', (atRule) => {
|
|
73
|
-
atRule.
|
|
73
|
+
const propName = atRule.params.trim();
|
|
74
|
+
if (!referencedVars.has(propName)) {
|
|
75
|
+
atRule.remove();
|
|
76
|
+
}
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
if (removeResolved) {
|
|
@@ -82,4 +85,28 @@ export const transformRoot = (root, staticVarMap, referencedVars, propertyNames,
|
|
|
82
85
|
}
|
|
83
86
|
});
|
|
84
87
|
}
|
|
88
|
+
removeEmptyContainers(root);
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Remove empty rules and `@layer` at-rules left behind after
|
|
92
|
+
* declarations and `@property` rules have been stripped.
|
|
93
|
+
* Walks bottom-up so nested empty containers are cleaned recursively.
|
|
94
|
+
*/
|
|
95
|
+
const removeEmptyContainers = (root) => {
|
|
96
|
+
let changed = true;
|
|
97
|
+
while (changed) {
|
|
98
|
+
changed = false;
|
|
99
|
+
root.walkRules((rule) => {
|
|
100
|
+
if (rule.nodes && rule.nodes.length === 0) {
|
|
101
|
+
rule.remove();
|
|
102
|
+
changed = true;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
root.walkAtRules('layer', (atRule) => {
|
|
106
|
+
if (atRule.nodes && atRule.nodes.length === 0) {
|
|
107
|
+
atRule.remove();
|
|
108
|
+
changed = true;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
85
112
|
};
|