File tree Expand file tree Collapse file tree 3 files changed +64
-2
lines changed
integrations/tailwindcss-cli/tests Expand file tree Collapse file tree 3 files changed +64
-2
lines changed Original file line number Diff line number Diff line change @@ -258,7 +258,7 @@ describe('Build command', () => {
258258
259259 expect ( combined ) . toMatchInlineSnapshot ( `
260260 "
261- tailwindcss v2.1.2
261+ tailwindcss v2.2.4
262262
263263 Usage:
264264 tailwindcss build [options]
@@ -348,7 +348,7 @@ describe('Init command', () => {
348348
349349 expect ( combined ) . toMatchInlineSnapshot ( `
350350 "
351- tailwindcss v2.1.2
351+ tailwindcss v2.2.4
352352
353353 Usage:
354354 tailwindcss init [options]
Original file line number Diff line number Diff line change @@ -132,6 +132,61 @@ describe('watcher', () => {
132132 return runningProcess . stop ( )
133133 } )
134134
135+ test ( '@layers are replaced and cleaned when the html file changes' , async ( ) => {
136+ await writeInputFile ( 'index.html' , html `<div class= "font-bold" > </ div> ` )
137+ await writeInputFile (
138+ 'index.css' ,
139+ css `
140+ @tailwind base;
141+ @tailwind components;
142+ @tailwind utilities;
143+
144+ @layer base {
145+ html {
146+ scroll-behavior : smooth;
147+ }
148+ }
149+ `
150+ )
151+
152+ let runningProcess = $ ( 'node ../../lib/cli.js -i ./src/index.css -o ./dist/main.css -w' )
153+
154+ await waitForOutputFileCreation ( 'main.css' )
155+
156+ expect ( await readOutputFile ( 'main.css' ) ) . toIncludeCss (
157+ css `
158+ .font-bold {
159+ font-weight : 700 ;
160+ }
161+ `
162+ )
163+
164+ await waitForOutputFileChange ( 'main.css' , async ( ) => {
165+ await appendToInputFile ( 'index.html' , html `<div class= "font-normal" > </ div> ` )
166+ } )
167+
168+ expect ( await readOutputFile ( 'main.css' ) ) . not . toIncludeCss ( css `
169+ @layer base {
170+ html {
171+ scroll-behavior : smooth;
172+ }
173+ }
174+ ` )
175+
176+ expect ( await readOutputFile ( 'main.css' ) ) . toIncludeCss (
177+ css `
178+ .font-bold {
179+ font-weight : 700 ;
180+ }
181+ .font-normal {
182+ font-weight : 400 ;
183+ }
184+ `
185+ )
186+
187+ return runningProcess . stop ( )
188+ } )
189+
135190 test ( 'classes are generated when the tailwind.config.js file changes' , async ( ) => {
136191 await writeInputFile ( 'index.html' , html `<div class= "font-bold md:font-medium" > </ div> ` )
137192
Original file line number Diff line number Diff line change @@ -238,5 +238,12 @@ export default function expandTailwindAtRules(context) {
238238
239239 // Clear the cache for the changed files
240240 context . changedContent = [ ]
241+
242+ // Cleanup any leftover @layer atrules
243+ root . walkAtRules ( 'layer' , ( rule ) => {
244+ if ( Object . keys ( layerNodes ) . includes ( rule . params ) ) {
245+ rule . remove ( )
246+ }
247+ } )
241248 }
242249}
You can’t perform that action at this time.
0 commit comments