tailwindcss() — tailwindcss Function Reference
Architecture documentation for the tailwindcss() function in index.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 6d05b300_c6ad_6d9d_74a4_394205536160["tailwindcss()"] 2bc39c56_196b_12bc_1a08_0896427ab477["index.ts"] 6d05b300_c6ad_6d9d_74a4_394205536160 -->|defined in| 2bc39c56_196b_12bc_1a08_0896427ab477 e1212b8d_4bcf_d4e1_be45_2cb2423dc171["fixRelativePathsPlugin()"] 6d05b300_c6ad_6d9d_74a4_394205536160 -->|calls| e1212b8d_4bcf_d4e1_be45_2cb2423dc171 db0a1c89_955b_8963_d8bc_904d275dbfa8["getContextFromCache()"] 6d05b300_c6ad_6d9d_74a4_394205536160 -->|calls| db0a1c89_955b_8963_d8bc_904d275dbfa8 63cea7e8_6a82_90d2_b2b0_c166362f218b["postCssAstToCssAst()"] 6d05b300_c6ad_6d9d_74a4_394205536160 -->|calls| 63cea7e8_6a82_90d2_b2b0_c166362f218b 9b49f3c6_0c8d_5c62_965c_30a1db6499f8["toCss()"] 6d05b300_c6ad_6d9d_74a4_394205536160 -->|calls| 9b49f3c6_0c8d_5c62_965c_30a1db6499f8 dea2012d_fe14_a673_2ce4_701a84a75cdb["cssAstToPostCssAst()"] 6d05b300_c6ad_6d9d_74a4_394205536160 -->|calls| dea2012d_fe14_a673_2ce4_701a84a75cdb style 6d05b300_c6ad_6d9d_74a4_394205536160 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-postcss/src/index.ts lines 71–363
function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
let base = opts.base ?? process.cwd()
let optimize = opts.optimize ?? process.env.NODE_ENV === 'production'
let shouldRewriteUrls = opts.transformAssetUrls ?? true
return {
postcssPlugin: '@tailwindcss/postcss',
plugins: [
// We need to handle the case where `postcss-import` might have run before
// the Tailwind CSS plugin is run. In this case, we need to manually fix
// relative paths before processing it in core.
fixRelativePathsPlugin(),
{
postcssPlugin: 'tailwindcss',
async Once(root, { result, postcss }) {
using I = new Instrumentation()
let inputFile = result.opts.from ?? ''
let isCSSModuleFile = inputFile.endsWith('.module.css')
DEBUG && I.start(`[@tailwindcss/postcss] ${relative(base, inputFile)}`)
// Bail out early if this is guaranteed to be a non-Tailwind CSS file.
{
DEBUG && I.start('Quick bail check')
let canBail = true
root.walkAtRules((node) => {
if (
node.name === 'import' ||
node.name === 'reference' ||
node.name === 'theme' ||
node.name === 'variant' ||
node.name === 'config' ||
node.name === 'plugin' ||
node.name === 'apply' ||
node.name === 'tailwind'
) {
canBail = false
return false
}
})
if (canBail) return
DEBUG && I.end('Quick bail check')
}
let context = getContextFromCache(postcss, inputFile, opts)
let inputBasePath = path.dirname(path.resolve(inputFile))
// Whether this is the first build or not, if it is, then we can
// optimize the build by not creating the compiler until we need it.
let isInitialBuild = context.compiler === null
async function createCompiler() {
DEBUG && I.start('Setup compiler')
if (context.fullRebuildPaths.length > 0 && !isInitialBuild) {
clearRequireCache(context.fullRebuildPaths)
}
context.fullRebuildPaths = []
DEBUG && I.start('PostCSS AST -> Tailwind CSS AST')
let ast = postCssAstToCssAst(root)
DEBUG && I.end('PostCSS AST -> Tailwind CSS AST')
DEBUG && I.start('Create compiler')
let compiler = await compileAst(ast, {
from: result.opts.from,
base: inputBasePath,
shouldRewriteUrls,
onDependency: (path) => context.fullRebuildPaths.push(path),
// In CSS Module files, we have to disable the `@property` polyfill since these will
// emit global `*` rules which are considered to be non-pure and will cause builds
// to fail.
polyfills: isCSSModuleFile ? Polyfills.All ^ Polyfills.AtProperty : Polyfills.All,
})
DEBUG && I.end('Create compiler')
DEBUG && I.end('Setup compiler')
return compiler
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does tailwindcss() do?
tailwindcss() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-postcss/src/index.ts.
Where is tailwindcss() defined?
tailwindcss() is defined in packages/@tailwindcss-postcss/src/index.ts at line 71.
What does tailwindcss() call?
tailwindcss() calls 5 function(s): cssAstToPostCssAst, fixRelativePathsPlugin, getContextFromCache, postCssAstToCssAst, toCss.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free