File tree 2 files changed +50
-1
lines changed
2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,21 @@ module.exports = function tailwindcss(configOrPath) {
13
13
return root
14
14
} ,
15
15
function ( root , result ) {
16
- processTailwindFeatures ( setupTrackingContext ( configOrPath ) ) ( root , result )
16
+ let context = setupTrackingContext ( configOrPath )
17
+
18
+ if ( root . type === 'document' ) {
19
+ let roots = root . nodes . filter ( ( node ) => node . type === 'root' )
20
+
21
+ for ( const root of roots ) {
22
+ if ( root . type === 'root' ) {
23
+ processTailwindFeatures ( context ) ( root , result )
24
+ }
25
+ }
26
+
27
+ return
28
+ }
29
+
30
+ processTailwindFeatures ( context ) ( root , result )
17
31
} ,
18
32
env . DEBUG &&
19
33
function ( root ) {
Original file line number Diff line number Diff line change 1
1
import fs from 'fs'
2
2
import path from 'path'
3
+ import postcss from 'postcss'
3
4
4
5
import { run , css , html , defaults } from './util/run'
5
6
@@ -539,3 +540,37 @@ it('variants for utilities should not be produced in a file without a utilities
539
540
` )
540
541
} )
541
542
} )
543
+
544
+ fit ( 'appends variants to the correct place when using postcss documents' , ( ) => {
545
+ let config = {
546
+ content : [ { raw : html `<div class= "underline sm:underline" > </ div> ` } ] ,
547
+ plugins : [ ] ,
548
+ corePlugins : { preflight : false } ,
549
+ }
550
+
551
+ const doc = postcss . document ( )
552
+ doc . append ( postcss . parse ( `a {}` ) )
553
+ doc . append ( postcss . parse ( `@tailwind base` ) )
554
+ doc . append ( postcss . parse ( `@tailwind utilities` ) )
555
+ doc . append ( postcss . parse ( `b {}` ) )
556
+
557
+ const result = doc . toResult ( )
558
+
559
+ return run ( result , config ) . then ( ( result ) => {
560
+ return expect ( result . css ) . toMatchFormattedCss ( css `
561
+ a {
562
+ }
563
+ ${ defaults }
564
+ .underline {
565
+ text-decoration-line : underline;
566
+ }
567
+ @media (min-width : 640px ) {
568
+ .sm\:underline {
569
+ text-decoration-line : underline;
570
+ }
571
+ }
572
+ b {
573
+ }
574
+ ` )
575
+ } )
576
+ } )
You can’t perform that action at this time.
0 commit comments