From aa665d3dcf5b69819912cd3c19f3d352e869208d Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Wed, 23 Oct 2024 17:38:39 +0200 Subject: [PATCH] =?UTF-8?q?forward=20correct=20`source(=E2=80=A6)`=20to=20?= =?UTF-8?q?the=20oxide=20scanner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/commands/build/index.ts | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/@tailwindcss-cli/src/commands/build/index.ts b/packages/@tailwindcss-cli/src/commands/build/index.ts index dc8ba2a90..41650e07b 100644 --- a/packages/@tailwindcss-cli/src/commands/build/index.ts +++ b/packages/@tailwindcss-cli/src/commands/build/index.ts @@ -137,16 +137,29 @@ export async function handle(args: Result>) { 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']) { @@ -205,13 +218,7 @@ export async function handle(args: Result>) { 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')