Skip to content

Commit

Permalink
forward correct source(…) to the oxide scanner
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Oct 24, 2024
1 parent 7e0c3dc commit 45edace
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions packages/@tailwindcss-cli/src/commands/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,29 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
fullRebuildPaths.push(path)
},
})

let detectSources = (() => {
// Disable auto source detection
if (compiler.root === 'none') {
return undefined
}

// No root specified, use the base directory
if (compiler.root === null) {
return { base }
}

// Use the specified root
return { base: path.resolve(compiler.root.base, compiler.root.pattern) }
})()

let scanner = new Scanner({ detectSources, sources: compiler.globs })
env.DEBUG && console.timeEnd('[@tailwindcss/cli] Setup compiler')
return compiler

return [compiler, scanner] as const
}

// Compile the input
let compiler = await createCompiler(input)
let scanner = new Scanner({
detectSources: { base },
sources: compiler.globs,
})
let [compiler, scanner] = await createCompiler(input)

// Watch for changes
if (args['--watch']) {
Expand Down Expand Up @@ -205,13 +218,7 @@ export async function handle(args: Result<ReturnType<typeof options>>) {
fullRebuildPaths = inputFilePath ? [inputFilePath] : []

// Create a new compiler, given the new `input`
compiler = await createCompiler(input)

// Re-scan the directory to get the new `candidates`
scanner = new Scanner({
detectSources: { base },
sources: compiler.globs,
})
;[compiler, scanner] = await createCompiler(input)

// Scan the directory for candidates
env.DEBUG && console.time('[@tailwindcss/cli] Scan for candidates')
Expand Down

0 comments on commit 45edace

Please sign in to comment.