@@ -137,16 +137,29 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
137
137
fullRebuildPaths . push ( path )
138
138
} ,
139
139
} )
140
+
141
+ let detectSources = ( ( ) => {
142
+ // Disable auto source detection
143
+ if ( compiler . root === 'none' ) {
144
+ return undefined
145
+ }
146
+
147
+ // No root specified, use the base directory
148
+ if ( compiler . root === null ) {
149
+ return { base }
150
+ }
151
+
152
+ // Use the specified root
153
+ return { base : path . resolve ( compiler . root . base , compiler . root . pattern ) }
154
+ } ) ( )
155
+
156
+ let scanner = new Scanner ( { detectSources, sources : compiler . globs } )
140
157
env . DEBUG && console . timeEnd ( '[@tailwindcss/cli] Setup compiler' )
141
- return compiler
158
+
159
+ return [ compiler , scanner ] as const
142
160
}
143
161
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 )
150
163
151
164
// Watch for changes
152
165
if ( args [ '--watch' ] ) {
@@ -205,13 +218,7 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
205
218
fullRebuildPaths = inputFilePath ? [ inputFilePath ] : [ ]
206
219
207
220
// 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 )
215
222
216
223
// Scan the directory for candidates
217
224
env . DEBUG && console . time ( '[@tailwindcss/cli] Scan for candidates' )
0 commit comments