@@ -137,16 +137,29 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
137137 fullRebuildPaths . push ( path )
138138 } ,
139139 } )
140+
141+ let sources = ( ( ) => {
142+ // Disable auto source detection
143+ if ( compiler . root === 'none' ) {
144+ return [ ]
145+ }
146+
147+ // No root specified, use the base directory
148+ if ( compiler . root === null ) {
149+ return [ { base, pattern : '**/*' } ]
150+ }
151+
152+ // Use the specified root
153+ return [ compiler . root ]
154+ } ) ( ) . concat ( compiler . globs )
155+
156+ let scanner = new Scanner ( { sources } )
140157 env . DEBUG && console . timeEnd ( '[@tailwindcss/cli] Setup compiler' )
141- return compiler
158+
159+ return [ compiler , scanner ] as const
142160 }
143161
144- // Compile the input
145- let compiler = await createCompiler ( input )
146- let scanner = new Scanner ( {
147- detectSources : { base } ,
148- sources : compiler . globs ,
149- } )
162+ let [ compiler , scanner ] = await createCompiler ( input )
150163
151164 // Watch for changes
152165 if ( args [ '--watch' ] ) {
@@ -205,13 +218,7 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
205218 fullRebuildPaths = inputFilePath ? [ inputFilePath ] : [ ]
206219
207220 // Create a new compiler, given the new `input`
208- compiler = await createCompiler ( input )
209-
210- // Re-scan the directory to get the new `candidates`
211- scanner = new Scanner ( {
212- detectSources : { base } ,
213- sources : compiler . globs ,
214- } )
221+ ; [ compiler , scanner ] = await createCompiler ( input )
215222
216223 // Scan the directory for candidates
217224 env . DEBUG && console . time ( '[@tailwindcss/cli] Scan for candidates' )
@@ -293,6 +300,9 @@ function watchDirectories(base: string, scanner: Scanner) {
293300 // We don't want a watcher for negated globs.
294301 if ( globEntry . pattern [ 0 ] === '!' ) return [ ]
295302
303+ // We don't want a watcher for files, only directories.
304+ if ( globEntry . pattern === '' ) return [ ]
305+
296306 // We don't want a watcher for nested directories, these will be covered
297307 // by the `base` directory already.
298308 if ( globEntry . base . startsWith ( base ) ) return [ ]
0 commit comments