diff --git a/CHANGELOG.md b/CHANGELOG.md index b6010f06b487..0f1e86276a96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Use configured `--letter-spacing` values for custom font size utilities ([#15099](https://github.com/tailwindlabs/tailwindcss/pull/15099)) - Ensure `space-x/y-*` and `divide-x/y-*` with variants can undo `space-x/y-reverse` and `divide-x/y-reverse` ([#15094](https://github.com/tailwindlabs/tailwindcss/pull/15094)) +- Don't print minified code when the build fails in the CLI ([#15106](https://github.com/tailwindlabs/tailwindcss/pull/15106)) - _Upgrade (experimental)_: Always add `layer(…)` as the first param to `@import` ([#15102](https://github.com/tailwindlabs/tailwindcss/pull/15102)) ### Changed diff --git a/packages/@tailwindcss-cli/src/commands/build/index.ts b/packages/@tailwindcss-cli/src/commands/build/index.ts index d36a3ab7c949..5c90d8ba3819 100644 --- a/packages/@tailwindcss-cli/src/commands/build/index.ts +++ b/packages/@tailwindcss-cli/src/commands/build/index.ts @@ -54,6 +54,17 @@ export function options() { } satisfies Arg } +async function handleError(fn: () => T): Promise { + try { + return await fn() + } catch (err) { + if (err instanceof Error) { + eprintln(err.toString()) + } + process.exit(1) + } +} + export async function handle(args: Result>) { let base = path.resolve(args['--cwd']) @@ -159,7 +170,7 @@ export async function handle(args: Result>) { return [compiler, scanner] as const } - let [compiler, scanner] = await createCompiler(input) + let [compiler, scanner] = await handleError(() => createCompiler(input)) // Watch for changes if (args['--watch']) { @@ -288,7 +299,7 @@ export async function handle(args: Result>) { let candidates = scanner.scan() env.DEBUG && console.timeEnd('[@tailwindcss/cli] Scan for candidates') env.DEBUG && console.time('[@tailwindcss/cli] Build CSS') - let output = compiler.build(candidates) + let output = await handleError(() => compiler.build(candidates)) env.DEBUG && console.timeEnd('[@tailwindcss/cli] Build CSS') await write(output, args)