parseCss() — tailwindcss Function Reference
Architecture documentation for the parseCss() function in index.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 3970218d_3d6c_e455_87cc_45b4a094f0e9["parseCss()"] 5af9cd3c_2cf4_9dee_376e_fc39122d865a["index.ts"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|defined in| 5af9cd3c_2cf4_9dee_376e_fc39122d865a ae5a4f96_ffbe_5d6f_324b_4caa358fe1fb["compileAst()"] ae5a4f96_ffbe_5d6f_324b_4caa358fe1fb -->|calls| 3970218d_3d6c_e455_87cc_45b4a094f0e9 28a4a0ba_405e_2b1a_b1d1_5f3944486a8f["__unstable__loadDesignSystem()"] 28a4a0ba_405e_2b1a_b1d1_5f3944486a8f -->|calls| 3970218d_3d6c_e455_87cc_45b4a094f0e9 5713e78d_1b82_b74a_13d9_da852136ec3c["substituteAtImports()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 5713e78d_1b82_b74a_13d9_da852136ec3c ed78da58_8727_ad98_120c_61f35cea357a["walk()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| ed78da58_8727_ad98_120c_61f35cea357a b50aa380_a654_a283_9fe1_91a9a42ca527["cssContext()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| b50aa380_a654_a283_9fe1_91a9a42ca527 f712ed47_45d4_4e5a_dd73_fdefa1da71da["segment()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| f712ed47_45d4_4e5a_dd73_fdefa1da71da 75cdf0b0_3569_52fd_7186_577645fd4872["createCssUtility()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 75cdf0b0_3569_52fd_7186_577645fd4872 4e82d568_7e90_60c3_1671_8ea6ca89c260["expand()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 4e82d568_7e90_60c3_1671_8ea6ca89c260 e37ec412_58f3_7fbe_3589_99329ee9b910["set()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| e37ec412_58f3_7fbe_3589_99329ee9b910 36be1773_d660_31ac_0b0b_88dbd7f6f7a8["styleRule()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 36be1773_d660_31ac_0b0b_88dbd7f6f7a8 759ab8d0_0e80_5789_e945_a5f814874e59["compoundsForSelectors()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 759ab8d0_0e80_5789_e945_a5f814874e59 06ed9408_12cf_7ddd_a435_8cdd942de1d4["add()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 06ed9408_12cf_7ddd_a435_8cdd942de1d4 34338b14_fec6_6308_0fd7_15af8d4da01b["fromAst()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 34338b14_fec6_6308_0fd7_15af8d4da01b style 3970218d_3d6c_e455_87cc_45b4a094f0e9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/index.ts lines 141–707
async function parseCss(
ast: AstNode[],
{
base = '',
from,
loadModule = throwOnLoadModule,
loadStylesheet = throwOnLoadStylesheet,
}: CompileOptions = {},
) {
let features = Features.None
ast = [contextNode({ base }, ast)] as AstNode[]
features |= await substituteAtImports(ast, base, loadStylesheet, 0, from !== undefined)
let important = null as boolean | null
let theme = new Theme()
let customVariants = new Map<string, (designSystem: DesignSystem) => void>()
let customVariantDependencies = new Map<string, Set<string>>()
let customUtilities: ((designSystem: DesignSystem) => void)[] = []
let firstThemeRule = null as StyleRule | null
let utilitiesNode = null as AtRule | null
let variantNodes: AtRule[] = []
let sources: { base: string; pattern: string; negated: boolean }[] = []
let inlineCandidates: string[] = []
let ignoredCandidates: string[] = []
let root = null as Root
// Handle at-rules
walk(ast, (node, _ctx) => {
if (node.kind !== 'at-rule') return
let ctx = cssContext(_ctx)
// Find `@tailwind utilities` so that we can later replace it with the
// actual generated utility class CSS.
if (
node.name === '@tailwind' &&
(node.params === 'utilities' || node.params.startsWith('utilities'))
) {
// Any additional `@tailwind utilities` nodes can be removed
if (utilitiesNode !== null) {
return WalkAction.Replace([])
}
// When inside `@reference` we should treat `@tailwind utilities` as if
// it wasn't there in the first place. This should also let `build()`
// return the cached static AST.
if (ctx.context.reference) {
return WalkAction.Replace([])
}
let params = segment(node.params, ' ')
for (let param of params) {
if (param.startsWith('source(')) {
let path = param.slice(7, -1)
// Keyword: `source(none)`
if (path === 'none') {
root = path
continue
}
// Explicit path: `source('…')`
if (
(path[0] === '"' && path[path.length - 1] !== '"') ||
(path[0] === "'" && path[path.length - 1] !== "'") ||
(path[0] !== "'" && path[0] !== '"')
) {
throw new Error('`source(…)` paths must be quoted.')
}
root = {
base: (ctx.context.sourceBase as string) ?? (ctx.context.base as string),
pattern: path.slice(1, -1),
}
}
}
utilitiesNode = node
features |= Features.Utilities
}
Domain
Subdomains
Defined In
Calls
- add()
- addKeyframes()
- applyCompatibilityHooks()
- atRoot()
- atRule()
- buildDesignSystem()
- compoundsForSelectors()
- context()
- createCssUtility()
- cssContext()
- decl()
- entries()
- escape()
- expand()
- fromAst()
- get()
- getKeyframes()
- keys()
- parseThemeOptions()
- rule()
- segment()
- set()
- styleRule()
- substituteAtApply()
- substituteAtImports()
- substituteAtVariant()
- substituteFunctions()
- theme()
- toCss()
- topologicalSort()
- unescape()
- walk()
Source
Frequently Asked Questions
What does parseCss() do?
parseCss() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/index.ts.
Where is parseCss() defined?
parseCss() is defined in packages/tailwindcss/src/index.ts at line 141.
What does parseCss() call?
parseCss() calls 32 function(s): add, addKeyframes, applyCompatibilityHooks, atRoot, atRule, buildDesignSystem, compoundsForSelectors, context, and 24 more.
What calls parseCss()?
parseCss() is called by 2 function(s): __unstable__loadDesignSystem, compileAst.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free