1
+ import dedent from 'dedent'
1
2
import { describe , expect } from 'vitest'
2
3
import { css , fetchStyles , html , retryAssertion , test , ts , txt } from '../utils'
3
4
@@ -30,7 +31,7 @@ function createSetup(transformer: 'postcss' | 'lightningcss') {
30
31
name : 'recolor' ,
31
32
transform (code, id) {
32
33
if (id.includes ('.css' )) {
33
- return code .replace (/ red/ g, 'blue' )
34
+ return code .replace (/ red; / g, 'blue; ' )
34
35
}
35
36
},
36
37
},
@@ -42,7 +43,7 @@ function createSetup(transformer: 'postcss' | 'lightningcss') {
42
43
<link rel= "stylesheet" href = "./src/index.css" / >
43
44
</ head>
44
45
<body>
45
- <div class= "foo" > Hello , world !</ div>
46
+ <div class= "foo [background-color:red] " > Hello , world !</ div>
46
47
</ body>
47
48
` ,
48
49
'src/index.css' : css `
@@ -59,7 +60,7 @@ function createSetup(transformer: 'postcss' | 'lightningcss') {
59
60
60
61
for ( let transformer of [ 'postcss' , 'lightningcss' ] as const ) {
61
62
describe ( transformer , ( ) => {
62
- test ( `production build` , createSetup ( transformer ) , async ( { fs, exec } ) => {
63
+ test . only ( `production build` , createSetup ( transformer ) , async ( { fs, exec } ) => {
63
64
await exec ( 'pnpm vite build' )
64
65
65
66
let files = await fs . glob ( 'dist/**/*.css' )
@@ -72,6 +73,12 @@ for (let transformer of ['postcss', 'lightningcss'] as const) {
72
73
color : blue;
73
74
}
74
75
` ,
76
+ // Running the transforms on utilities generated by Tailwind might change in the future
77
+ dedent `
78
+ .\[background-color\:red \] {
79
+ background-color : blue;
80
+ }
81
+ ` ,
75
82
] )
76
83
} )
77
84
@@ -86,6 +93,12 @@ for (let transformer of ['postcss', 'lightningcss'] as const) {
86
93
color : blue;
87
94
}
88
95
` )
96
+ // Running the transforms on utilities generated by Tailwind might change in the future
97
+ expect ( styles ) . toContain ( dedent `
98
+ .\[background-color\:red \] {
99
+ background-color : blue;
100
+ }
101
+ ` )
89
102
} )
90
103
91
104
await retryAssertion ( async ( ) => {
@@ -123,6 +136,12 @@ for (let transformer of ['postcss', 'lightningcss'] as const) {
123
136
color : blue;
124
137
}
125
138
` )
139
+ // Running the transforms on utilities generated by Tailwind might change in the future
140
+ expect ( styles ) . toContain ( dedent `
141
+ .\[background-color\:red \] {
142
+ background-color : blue;
143
+ }
144
+ ` )
126
145
} )
127
146
128
147
await retryAssertion ( async ( ) => {
0 commit comments