diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d886c914..366e11780 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add `--silent` option to suppress output in `@tailwindcss/cli` ([#20100](https://github.com/tailwindlabs/tailwindcss/pull/20100)) + ### Fixed - Remove deprecation warnings by using `Module#registerHooks` instead of `Module#register` on Node 26+ ([#20028](https://github.com/tailwindlabs/tailwindcss/pull/20028)) diff --git a/integrations/cli/index.test.ts b/integrations/cli/index.test.ts index 409a9de7c..f56cd765e 100644 --- a/integrations/cli/index.test.ts +++ b/integrations/cli/index.test.ts @@ -2217,6 +2217,49 @@ test( }, ) +test( + 'suppress output by using the --silent flag', + { + fs: { + 'package.json': json` + { + "dependencies": { + "tailwindcss": "workspace:^", + "@tailwindcss/cli": "workspace:^" + } + } + `, + 'index.css': css` @import 'tailwindcss/utilities';`, + 'index.html': html`
`, + }, + }, + async ({ fs, exec, expect }) => { + let output = await exec('pnpm tailwindcss --input index.css --output dist/loud.css') + expect(output).toContain('Done in') + + let silentOutput = await exec( + 'pnpm tailwindcss --input index.css --output dist/silent.css --silent', + ) + expect(silentOutput).not.toContain('Done in') + expect(silentOutput).not.toContain('tailwindcss v') + + expect(await fs.dumpFiles('./dist/*.css')).toMatchInlineSnapshot(` + " + --- ./dist/loud.css --- + .flex { + display: flex; + } + + + --- ./dist/silent.css --- + .flex { + display: flex; + } + " + `) + }, +) + test( 'changes to CSS files should pick up new CSS variables (if any)', { diff --git a/packages/@tailwindcss-cli/src/commands/build/index.ts b/packages/@tailwindcss-cli/src/commands/build/index.ts index eabd2a1de..01d646a6a 100644 --- a/packages/@tailwindcss-cli/src/commands/build/index.ts +++ b/packages/@tailwindcss-cli/src/commands/build/index.ts @@ -66,6 +66,10 @@ export function options() { description: 'Generate a source map', default: false, }, + '--silent': { + type: 'boolean', + description: 'Suppress non-error output', + }, } satisfies Arg } @@ -81,8 +85,8 @@ async function handleError