compile()
Compile a CSS string containing Tailwind directives into optimized CSS output.Parameters
string
required
The input CSS string containing Tailwind directives like
@tailwind utilities, @theme, @variant, etc.CompileOptions
Optional compilation options
Return Value
array
Array of source patterns discovered from
@source directives.Root
Root configuration extracted from
source() parameters in @tailwind utilities.Can be:null- No root specified'none'- Explicitly disabled viasource(none){ base: string; pattern: string }- Explicit pattern
Features
Bitmask of features detected in the CSS:
Features.AtApply-@applywas usedFeatures.AtImport-@importwas usedFeatures.JsPluginCompat-@pluginor@configwas usedFeatures.ThemeFunction-theme()function was usedFeatures.Utilities-@tailwind utilitieswas usedFeatures.Variants-@variantwas usedFeatures.AtTheme-@themewas used
function
Function to generate CSS for a given set of candidates.Returns the compiled CSS string. Automatically caches results - if the same candidates are provided, returns the cached output without recompilation.
function
Function to generate a source map for the compiled CSS.
Example Usage
compileAst()
Compile a pre-parsed AST instead of a CSS string. This is useful when you already have an AST from the CSS parser.Parameters
AstNode[]
required
Array of AST nodes from the CSS parser.
CompileOptions
Same options as
compile() function. See above for details.Return Value
Returns the same structure ascompile(), except the build() function returns AstNode[] instead of a string, and there is no buildSourceMap() function.
function
Function to generate an AST for a given set of candidates.Returns an array of AST nodes that can be further processed or converted to CSS using
toCss().