From b1e2c8fd5cb5dfa46bc440a12eafaf56cd844b1c Mon Sep 17 00:00:00 2001 From: Philipp Tanlak Date: Mon, 24 Nov 2025 20:54:57 +0100 Subject: Docs --- node_modules/tailwindcss/src/lib/detectNesting.js | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 node_modules/tailwindcss/src/lib/detectNesting.js (limited to 'node_modules/tailwindcss/src/lib/detectNesting.js') diff --git a/node_modules/tailwindcss/src/lib/detectNesting.js b/node_modules/tailwindcss/src/lib/detectNesting.js new file mode 100644 index 0000000..03252e2 --- /dev/null +++ b/node_modules/tailwindcss/src/lib/detectNesting.js @@ -0,0 +1,47 @@ +function isRoot(node) { + return node.type === 'root' +} + +function isAtLayer(node) { + return node.type === 'atrule' && node.name === 'layer' +} + +export default function (_context) { + return (root, result) => { + let found = false + + root.walkAtRules('tailwind', (node) => { + if (found) return false + + if (node.parent && !(isRoot(node.parent) || isAtLayer(node.parent))) { + found = true + node.warn( + result, + [ + 'Nested @tailwind rules were detected, but are not supported.', + "Consider using a prefix to scope Tailwind's classes: https://tailwindcss.com/docs/configuration#prefix", + 'Alternatively, use the important selector strategy: https://tailwindcss.com/docs/configuration#selector-strategy', + ].join('\n') + ) + return false + } + }) + + root.walkRules((rule) => { + if (found) return false + + rule.walkRules((nestedRule) => { + found = true + nestedRule.warn( + result, + [ + 'Nested CSS was detected, but CSS nesting has not been configured correctly.', + 'Please enable a CSS nesting plugin *before* Tailwind in your configuration.', + 'See how here: https://tailwindcss.com/docs/using-with-preprocessors#nesting', + ].join('\n') + ) + return false + }) + }) + } +} -- cgit v1.2.3