postCssAstToCssAst() — tailwindcss Function Reference
Architecture documentation for the postCssAstToCssAst() function in ast.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 3b7b5721_2ad8_b95c_e5b3_704c1dbf9939["postCssAstToCssAst()"] f4282831_f22b_2be1_4c8f_449ba7a9c8d7["tailwindcss()"] f4282831_f22b_2be1_4c8f_449ba7a9c8d7 -->|calls| 3b7b5721_2ad8_b95c_e5b3_704c1dbf9939 669adbf7_1255_4fed_e741_941fd5e91726["compiler()"] 669adbf7_1255_4fed_e741_941fd5e91726 -->|calls| 3b7b5721_2ad8_b95c_e5b3_704c1dbf9939 0aa64a1c_efd8_a69d_48ed_649b7a86c854["get()"] 3b7b5721_2ad8_b95c_e5b3_704c1dbf9939 -->|calls| 0aa64a1c_efd8_a69d_48ed_649b7a86c854 47ef7bd7_b959_59c4_dbd1_328f35d7cd89["decl()"] 3b7b5721_2ad8_b95c_e5b3_704c1dbf9939 -->|calls| 47ef7bd7_b959_59c4_dbd1_328f35d7cd89 f4f92a3d_c13e_a751_8402_451ffa4c772f["rule()"] 3b7b5721_2ad8_b95c_e5b3_704c1dbf9939 -->|calls| f4f92a3d_c13e_a751_8402_451ffa4c772f c35acfc6_964d_737e_6ecc_275e6f10293a["atRule()"] 3b7b5721_2ad8_b95c_e5b3_704c1dbf9939 -->|calls| c35acfc6_964d_737e_6ecc_275e6f10293a f4c1885c_39a0_4343_f87c_7a8b1145a3bc["comment()"] 3b7b5721_2ad8_b95c_e5b3_704c1dbf9939 -->|calls| f4c1885c_39a0_4343_f87c_7a8b1145a3bc style 3b7b5721_2ad8_b95c_e5b3_704c1dbf9939 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