Installation
Install the@tailwindcss/cli package globally or in your project:
Basic Usage
The CLI processes your CSS files and generates the output with all Tailwind utilities:Watch Mode
Use watch mode to automatically rebuild your CSS when files change:--watch=always to keep watching even when stdin closes:
Input and Output
Using stdin and stdout
You can pipe CSS through the CLI using stdin and stdout:- flag explicitly:
Specifying Files
Use the--input and --output flags to specify file paths:
Optimization
Minification
Optimize and minify your output for production:Optimization Without Minification
If you want to optimize the CSS without minifying it:Source Maps
Inline Source Maps
Generate inline source maps for debugging:External Source Maps
Write source maps to a separate file:Working Directory
Specify the current working directory for relative paths:Command Reference
Options
Input CSS file path. Use
- for stdin. Defaults to a built-in CSS file that imports Tailwind.Alias: -iOutput CSS file path. Use
- for stdout.Alias: -oDefault: - (stdout)Watch for changes and rebuild as needed. Use
always to keep watching when stdin is closed.Alias: -wOptimize and minify the output CSS.Alias:
-mOptimize the output without minifying.
The current working directory for resolving relative paths.Default:
. (current directory)Generate a source map. Pass
true for inline maps or a file path for external maps.Default: falseDisplay usage information.Alias:
-hExamples
Development Build
Build with watch mode and source maps for development:Production Build
Build with minification for production:Using with npm scripts
Add scripts to yourpackage.json:
How It Works
The CLI performs the following steps:- Reads input - Processes the input CSS file (or stdin)
- Scans content - Automatically scans your project files for Tailwind class names
- Compiles CSS - Generates CSS for all detected utilities
- Optimizes - Optionally minifies and optimizes the output
- Writes output - Saves to the output file (or stdout)
- Your input CSS file changes (full rebuild)
- Your configuration or plugin files change (full rebuild)
- Your content files change (incremental rebuild)
The CLI uses the Rust-based scanner from
@tailwindcss/oxide for extremely fast candidate detection across your entire project.