postCssAstToCssAst() — tailwindcss Function Reference
Architecture documentation for the postCssAstToCssAst() function in ast.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD c90ec073_0241_abd8_3427_8edf14bd20d2["postCssAstToCssAst()"] f3a29437_b991_0a27_2561_a76b3f340642["tailwindcss()"] f3a29437_b991_0a27_2561_a76b3f340642 -->|calls| c90ec073_0241_abd8_3427_8edf14bd20d2 48809bde_54f2_e8e3_6b2c_2861fdc49d90["compiler()"] 48809bde_54f2_e8e3_6b2c_2861fdc49d90 -->|calls| c90ec073_0241_abd8_3427_8edf14bd20d2 4cd99e59_ac1e_2a1f_0946_33cc1afd2532["get()"] c90ec073_0241_abd8_3427_8edf14bd20d2 -->|calls| 4cd99e59_ac1e_2a1f_0946_33cc1afd2532 85b46de2_edfa_9371_e2c6_e60f3f5346a2["decl()"] c90ec073_0241_abd8_3427_8edf14bd20d2 -->|calls| 85b46de2_edfa_9371_e2c6_e60f3f5346a2 08f33202_11d1_569a_e8df_de23eb987e2f["rule()"] c90ec073_0241_abd8_3427_8edf14bd20d2 -->|calls| 08f33202_11d1_569a_e8df_de23eb987e2f a9af385a_fd12_f1d8_7cf0_ccb9b281ca18["atRule()"] c90ec073_0241_abd8_3427_8edf14bd20d2 -->|calls| a9af385a_fd12_f1d8_7cf0_ccb9b281ca18 dbaac8a3_b27b_2942_9a4d_7e9063a9649d["comment()"] c90ec073_0241_abd8_3427_8edf14bd20d2 -->|calls| dbaac8a3_b27b_2942_9a4d_7e9063a9649d style c90ec073_0241_abd8_3427_8edf14bd20d2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-postcss/src/ast.ts lines 126–189
export function postCssAstToCssAst(root: postcss.Root): AstNode[] {
let inputMap = new DefaultMap<postcss.Input, Source>((input) => ({
file: input.file ?? input.id ?? null,
code: input.css,
}))
function toSource(node: postcss.ChildNode): SourceLocation | undefined {
let source = node.source
if (!source) return
let input = source.input
if (!input) return
if (source.start === undefined) return
if (source.end === undefined) return
return [inputMap.get(input), source.start.offset, source.end.offset]
}
function transform(
node: postcss.ChildNode,
parent: Extract<AstNode, { nodes: AstNode[] }>['nodes'],
) {
// Declaration
if (node.type === 'decl') {
let astNode = decl(node.prop, node.value, node.important)
astNode.src = toSource(node)
parent.push(astNode)
}
// Rule
else if (node.type === 'rule') {
let astNode = rule(node.selector)
astNode.src = toSource(node)
node.each((child) => transform(child, astNode.nodes))
parent.push(astNode)
}
// AtRule
else if (node.type === 'atrule') {
let astNode = atRule(`@${node.name}`, node.params)
astNode.src = toSource(node)
node.each((child) => transform(child, astNode.nodes))
parent.push(astNode)
}
// Comment
else if (node.type === 'comment') {
if (node.text.charCodeAt(0) !== EXCLAMATION_MARK) return
let astNode = comment(node.text)
astNode.src = toSource(node)
parent.push(astNode)
}
// Unknown
else {
node satisfies never
}
}
let ast: AstNode[] = []
root.each((node) => transform(node, ast))
return ast
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does postCssAstToCssAst() do?
postCssAstToCssAst() is a function in the tailwindcss codebase.
What does postCssAstToCssAst() call?
postCssAstToCssAst() calls 5 function(s): atRule, comment, decl, get, rule.
What calls postCssAstToCssAst()?
postCssAstToCssAst() is called by 2 function(s): compiler, tailwindcss.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free