From 252047029d802b3704a8b367a480d4881096b06e Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 15 Jun 2026 16:19:58 +0200 Subject: [PATCH 1/4] add failing test --- integrations/cli/index.test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/integrations/cli/index.test.ts b/integrations/cli/index.test.ts index 75869ee32bd6..82d159707ea2 100644 --- a/integrations/cli/index.test.ts +++ b/integrations/cli/index.test.ts @@ -375,6 +375,35 @@ describe.each([ }, ) + test( + "watch mode with unknown @source paths shouldn't crash on Windows", + { + fs: { + 'package.json': json` + { + "dependencies": { + "tailwindcss": "workspace:^", + "@tailwindcss/cli": "workspace:^" + } + } + `, + 'index.html': html` +
+ `, + 'src/index.css': css` + @import 'tailwindcss'; + @source "uknown-folder/**/*"; + `, + }, + }, + async ({ fs, spawn }) => { + let process = await spawn(`${command} --input src/index.css --output dist/out.css --watch`) + await process.onStderr((m) => m.includes('Done in')) + + await fs.expectFileToContain('dist/out.css', [candidate`underline`]) + }, + ) + test( 'production build (stdin)', { From 87f536053c34192541550783a0ad3a6893259411 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 15 Jun 2026 16:49:10 +0200 Subject: [PATCH 2/4] only watch directories that exist At least at this point in time. We'll pass through the absolutely resolved real path. --- .../src/commands/build/index.ts | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/packages/@tailwindcss-cli/src/commands/build/index.ts b/packages/@tailwindcss-cli/src/commands/build/index.ts index 91365763392f..b8b11a6e45d9 100644 --- a/packages/@tailwindcss-cli/src/commands/build/index.ts +++ b/packages/@tailwindcss-cli/src/commands/build/index.ts @@ -272,7 +272,7 @@ export async function handle(args: Result>) { if (args['--watch']) { let cleanupWatchers: (() => Promise)[] = [] cleanupWatchers.push( - await createWatchers(watchDirectories(scanner), async function handle(files) { + await createWatchers(await watchDirectories(scanner), async function handle(files) { try { // If the only change happened to the output file, then we don't want to // trigger a rebuild because that will result in an infinite loop. @@ -347,7 +347,7 @@ export async function handle(args: Result>) { // Setup new watchers DEBUG && I.start('Setup new watchers') - let newCleanupFunction = await createWatchers(watchDirectories(scanner), handle) + let newCleanupFunction = await createWatchers(await watchDirectories(scanner), handle) DEBUG && I.end('Setup new watchers') // Clear old watchers @@ -586,8 +586,22 @@ async function createWatchers(dirs: string[], cb: (files: string[]) => void) { } } -function watchDirectories(scanner: Scanner) { - return [...new Set(scanner.normalizedSources.flatMap((globEntry) => globEntry.base))] +async function watchDirectories(scanner: Scanner) { + let directories = ( + await Promise.all( + scanner.normalizedSources.map(async (globEntry) => { + let resolvedPath = path.resolve(globEntry.base) + let realPath = await fs.realpath(resolvedPath).catch(() => resolvedPath) + + return fs + .stat(realPath) + .then((stat) => (stat.isDirectory() ? [realPath] : [])) + .catch(() => []) + }), + ) + ).flat(1) + + return Array.from(new Set(directories)) } function dim(str: string) { From e82f7ea3aa673cdaa739d8d5f0e182c3d8d154b7 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 15 Jun 2026 16:57:04 +0200 Subject: [PATCH 3/4] update changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9edab04ed619..b6e8e5b878f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Fixed + +- Ensure `@tailwindcss/cli` in `--watch` mode doesn't crash on Windows when `@source` points to a directory that doesn't exist ([#20242](https://github.com/tailwindlabs/tailwindcss/pull/20242)) ## [4.3.1] - 2026-06-12 From 22e29a0d3aeebc28855575c6e8508c64ac6ae131 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 15 Jun 2026 17:20:22 +0200 Subject: [PATCH 4/4] Update integrations/cli/index.test.ts Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- integrations/cli/index.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/cli/index.test.ts b/integrations/cli/index.test.ts index 82d159707ea2..4be12d9a1a48 100644 --- a/integrations/cli/index.test.ts +++ b/integrations/cli/index.test.ts @@ -392,7 +392,7 @@ describe.each([ `, 'src/index.css': css` @import 'tailwindcss'; - @source "uknown-folder/**/*"; + @source "unknown-folder/**/*"; `, }, },