Skip to content

Commit c69e76a

Browse files
committed
fix: v4 layer rules
1 parent 3da8f36 commit c69e76a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/removeUnsupported.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ module.exports = (options = { debug: false }) => {
4545
media(mediaAtRule) {
4646
mediaAtRule.remove();
4747
},
48+
49+
// Tailwind v4 wraps most output in @layer blocks (base/theme/utilities).
50+
// NativeScript's CSS engine does not implement CSS Cascade Layers,
51+
// so rules inside @layer would otherwise be ignored.
52+
//
53+
// Flatten those layers by lifting their child rules into the parent,
54+
// preserving order so specificity/cascade still work as expected.
55+
layer(layerAtRule) {
56+
if (!layerAtRule.nodes || !layerAtRule.nodes.length) {
57+
return layerAtRule.remove();
58+
}
59+
60+
layerAtRule.replaceWith(...layerAtRule.nodes);
61+
},
4862
},
4963
// Uncomment to debug the final output
5064
// OnceExit(rule) {

0 commit comments

Comments
 (0)