1
+ const { writeFileSync } = require ( "fs" ) ;
2
+
1
3
const remRE = / \d ? \. ? \d + \s * r ? e m / g;
2
4
3
5
function isSupportedProperty ( prop , val = null ) {
@@ -44,6 +46,10 @@ module.exports = (options = { debug: false }) => {
44
46
mediaAtRule . remove ( ) ;
45
47
} ,
46
48
} ,
49
+ // Uncomment to debug the final output
50
+ // OnceExit(rule) {
51
+ // writeFileSync('./tailwind-output.css', rule.toString());
52
+ // },
47
53
Rule ( rule ) {
48
54
// remove empty rules
49
55
if ( rule . nodes . length === 0 ) {
@@ -90,7 +96,14 @@ module.exports = (options = { debug: false }) => {
90
96
) ;
91
97
}
92
98
93
- // replace space and divide selectors to use a simpler selector that works in ns
99
+ // replace space and divide selectors to use a simpler selector that works in ns (v4 and newer)
100
+ if ( rule . selector . includes ( ":not(:last-child)" ) ) {
101
+ rule . selectors = rule . selectors . map ( ( selector ) => {
102
+ return selector . replace ( ":not(:last-child)" , "* + *" ) ;
103
+ } ) ;
104
+ }
105
+
106
+ // replace space and divide selectors to use a simpler selector that works in ns (older versions)
94
107
if ( rule . selector . includes ( ":not([hidden]) ~ :not([hidden])" ) ) {
95
108
rule . selectors = rule . selectors . map ( ( selector ) => {
96
109
return selector . replace ( ":not([hidden]) ~ :not([hidden])" , "* + *" ) ;
@@ -107,6 +120,16 @@ module.exports = (options = { debug: false }) => {
107
120
}
108
121
}
109
122
123
+ // tailvind v4 changed how the divide and space utilities work, now we need to set two variables called
124
+ // --tw-divide-x-reverse and --tw-divide-y-reverse but for them to work we need to remove the variable
125
+ // declarations from the divide and space utilities classes
126
+ const broken = / - - t w - ( d i v i d e | s p a c e ) - [ x y ] - r e v e r s e / g;
127
+
128
+ if ( decl . prop ?. match ( broken ) && decl . parent . selector ?. match ( / \. ( d i v i d e | s p a c e ) - [ x y ] / ) ) {
129
+ return decl . remove ( ) ;
130
+ }
131
+
132
+
110
133
// invalid with core 8.8+ at moment
111
134
// Note: could be supported at somepoint
112
135
if ( decl . prop === "placeholder-color" && decl . value ?. includes ( "color-mix" ) ) {
@@ -226,6 +249,7 @@ const supportedProperties = {
226
249
"font-size" : true ,
227
250
"font-style" : [ "italic" , "normal" ] ,
228
251
"font-weight" : true ,
252
+ "font-variation-settings" : true ,
229
253
height : true ,
230
254
"highlight-color" : true ,
231
255
"horizontal-align" : [ "left" , "center" , "right" , "stretch" ] ,
@@ -271,6 +295,7 @@ const supportedProperties = {
271
295
"text-shadow" : true ,
272
296
"text-transform" : [ "none" , "capitalize" , "uppercase" , "lowercase" ] ,
273
297
transform : true ,
298
+ rotate : true ,
274
299
"vertical-align" : [ "top" , "center" , "bottom" , "stretch" ] ,
275
300
visibility : [ "visible" , "collapse" ] ,
276
301
width : true ,
0 commit comments