Replies: 3 comments
-
If you're running Tailwind CSS as a PostCSS plugin, you could consider having a (custom) PostCSS plugin that runs after Tailwind CSS that converts the syntax to something compatible. Otherwise, you'd still have to run some sort of processor after Tailwind's compilation. |
Beta Was this translation helpful? Give feedback.
-
The reason you can’t find a configuration is because v4 targets Baseline 2023 (see: https://tailwindcss.com/docs/compatibility), where this is available by default. As wongjn mentioned, use TailwindCSS in PostCSS and write a custom PostCSS plugin to remove
Highlighting the key point, you need to do something like this:
postcss.config.mjs import tailwindcss from "@tailwindcss/postcss"
// Custom PostCSS plugin to remove `@layer` rules but keep the CSS inside
const removeLayerRules = (root) => {
root.walkAtRules('layer', (rule) => {
rule.replaceWith(rule.nodes);
});
};
// Custom PostCSS plugin to remove `@property` rules
const removePropertyRules = (root) => {
root.walkAtRules('property', (rule) => {
rule.remove();
});
};
// Custom PostCSS plugin to remove `@supports` rules (handle nested)
const removeSupportsRules = (root) => {
let hasSupports = true;
while (hasSupports) {
hasSupports = false;
root.walkAtRules('supports', (rule) => {
hasSupports = true;
rule.replaceWith(rule.nodes);
});
}
};
export default {
plugins: [
tailwindcss({
optimize: true, /* can set it to false if, for some reason, you don't want a minified output */
}),
removeLayerRules,
removePropertyRules,
removeSupportsRules,
]
} |
Beta Was this translation helpful? Give feedback.
-
Or you could also look at Preflight - If you import it manually, you can skip the layers: @import "tailwindcss/theme.css";
@import "tailwindcss/preflight.css";
@import "tailwindcss/utilities.css"; But unfortunately, |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The @layer properties syntax is not supported in some environments, such as WeChat mini apps.
I cannot find any configuration documentation for v4, so I have no idea how to solve this problem.
Generated CSS:
And escaped selector syntax:
Beta Was this translation helpful? Give feedback.
All reactions