@@ -134,11 +134,23 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
134134 }
135135
136136 if ( context . scanner === null || rebuildStrategy === 'full' ) {
137+ let sources = ( ( ) => {
138+ // Disable auto source detection
139+ if ( context . compiler . root === 'none' ) {
140+ return [ ]
141+ }
142+
143+ // No root specified, use the base directory
144+ if ( context . compiler . root === null ) {
145+ return [ { base, pattern : '**/*' } ]
146+ }
147+
148+ // Use the specified root
149+ return [ context . compiler . root ]
150+ } ) ( ) . concat ( context . compiler . globs )
151+
137152 // Look for candidates used to generate the CSS
138- context . scanner = new Scanner ( {
139- detectSources : { base } ,
140- sources : context . compiler . globs ,
141- } )
153+ context . scanner = new Scanner ( { sources } )
142154 }
143155
144156 env . DEBUG && console . time ( '[@tailwindcss/postcss] Scan for candidates' )
@@ -159,13 +171,22 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
159171 // giving tools like Vite or Parcel a glob that can be used to limit
160172 // the files that cause a rebuild to only those that match it.
161173 for ( let { base, pattern } of context . scanner . globs ) {
162- result . messages . push ( {
163- type : 'dir-dependency' ,
164- plugin : '@tailwindcss/postcss' ,
165- dir : base ,
166- glob : pattern ,
167- parent : result . opts . from ,
168- } )
174+ if ( pattern === '' ) {
175+ result . messages . push ( {
176+ type : 'dependency' ,
177+ plugin : '@tailwindcss/postcss' ,
178+ file : base ,
179+ parent : result . opts . from ,
180+ } )
181+ } else {
182+ result . messages . push ( {
183+ type : 'dir-dependency' ,
184+ plugin : '@tailwindcss/postcss' ,
185+ dir : base ,
186+ glob : pattern ,
187+ parent : result . opts . from ,
188+ } )
189+ }
169190 }
170191
171192 env . DEBUG && console . time ( '[@tailwindcss/postcss] Build CSS' )
0 commit comments