mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
18 lines
494 B
JavaScript
18 lines
494 B
JavaScript
function indentRecursive(node, indent = 0) {
|
|
node.each &&
|
|
node.each((child, i) => {
|
|
if (!child.raws.before || child.raws.before.includes('\n')) {
|
|
child.raws.before = `\n${node.type !== 'rule' && i > 0 ? '\n' : ''}${' '.repeat(indent)}`
|
|
}
|
|
child.raws.after = `\n${' '.repeat(indent)}`
|
|
indentRecursive(child, indent + 1)
|
|
})
|
|
}
|
|
|
|
export default function formatNodes(root) {
|
|
indentRecursive(root)
|
|
if (root.first) {
|
|
root.first.raws.before = ''
|
|
}
|
|
}
|