1+ const { writeFileSync } = require ( "fs" ) ;
2+
13const remRE = / \d ? \. ? \d + \s * r ? e m / g;
24
35function isSupportedProperty ( prop , val = null ) {
@@ -44,6 +46,10 @@ module.exports = (options = { debug: false }) => {
4446 mediaAtRule . remove ( ) ;
4547 } ,
4648 } ,
49+ // Uncomment to debug the final output
50+ // OnceExit(rule) {
51+ // writeFileSync('./tailwind-output.css', rule.toString());
52+ // },
4753 Rule ( rule ) {
4854 // remove empty rules
4955 if ( rule . nodes . length === 0 ) {
@@ -90,7 +96,14 @@ module.exports = (options = { debug: false }) => {
9096 ) ;
9197 }
9298
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)
94107 if ( rule . selector . includes ( ":not([hidden]) ~ :not([hidden])" ) ) {
95108 rule . selectors = rule . selectors . map ( ( selector ) => {
96109 return selector . replace ( ":not([hidden]) ~ :not([hidden])" , "* + *" ) ;
@@ -107,6 +120,16 @@ module.exports = (options = { debug: false }) => {
107120 }
108121 }
109122
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+
110133 // invalid with core 8.8+ at moment
111134 // Note: could be supported at somepoint
112135 if ( decl . prop === "placeholder-color" && decl . value ?. includes ( "color-mix" ) ) {
@@ -226,6 +249,7 @@ const supportedProperties = {
226249 "font-size" : true ,
227250 "font-style" : [ "italic" , "normal" ] ,
228251 "font-weight" : true ,
252+ "font-variation-settings" : true ,
229253 height : true ,
230254 "highlight-color" : true ,
231255 "horizontal-align" : [ "left" , "center" , "right" , "stretch" ] ,
@@ -271,6 +295,7 @@ const supportedProperties = {
271295 "text-shadow" : true ,
272296 "text-transform" : [ "none" , "capitalize" , "uppercase" , "lowercase" ] ,
273297 transform : true ,
298+ rotate : true ,
274299 "vertical-align" : [ "top" , "center" , "bottom" , "stretch" ] ,
275300 visibility : [ "visible" , "collapse" ] ,
276301 width : true ,
0 commit comments