-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
applyComplexClasses compiler stuck with @apply inside media queries or variants #2192
Comments
This should be fixed mainly because it bugs also when you apply custom selectors where you don't have variants in the
Where |
This is a tough one to fix but I'm sure we can sort it out. In the mean time I would move your nesting plugin before Tailwind so that there is no nested CSS left once the CSS is processed by Tailwind. |
@adamwathan I moved postcss-nested before Tailwind plugin, but still my build stuck
|
@AndrewBogdanovTSS Can you share a repository that reproduces the issue? Way too hard to troubleshoot without unfortunately. |
Edit: removed because not relevant to this issue |
Please for the love of god someone just make a GitHub repository so I don't have to make one from scratch and I can probably fix it in 5 minutes between dad duty, but if I have to do it all myself it'll be days before I have a chance to play with it. |
@adamwathan Created one for you: https://github.com/thecrypticace/at-apply-stuck |
I'll note that it seems to get stuck with or without |
The bubble option in module.exports = {
plugins: {
'postcss-nested': {
bubble: ['screen'],
},
tailwindcss: {},
},
} But it's not bubbling them :/ |
Actually nevermind the problem is the reproduction is setup incorrectly, it has a postcss.config.js file but it's using I've set it up correctly and verified it's a bug in postcss-nested that prevents this from working currently unfortunately. One fix I can think of is to write a separate PostCSS plugin that converts screen rules to media queries and switch to Here's my repo which shows the current bug: https://github.com/adamwathan/at-apply-stuck |
This is the bug we'd need to fix to have this working sensibly: Best solution currently is just to not nest screen rules if you need to use apply, write them at the root level like regular CSS instead for now. |
Ah whoops, sorry about that. |
Since it still gets stuck w/o postcss-nested should tailwind still detect that and handle it gracefully (at least not seeming get stuck in a loop)? |
It should probably just actually work so if we are going to make any changes to Tailwind making it work is the change I'd want to make. Just trying to offer some workaround in the mean time while I'm at some adventure farm with my 2 year old. |
You're awesome, next time I'll make a github with the problem sorry for my slack |
Making this work work is going to be a bit challenging but necessary anyways since there is a real CSS nesting spec and it's gonna probably exist for real one day. Just a note for myself, I think the correct algorithm for applying styles in these situations is to generate the "applyable" selector (with the TAILWIND-APPLY-PLACEHOLDER attribute selector), and split it on the placeholder, then stick the first half on the beginning of the first selector in the tree, and the last half at the end of the last selector in the tree. Example: .foo {
.bar {
.baz {
@apply group-hover:opacity-50 hover:font-bold;
// Applyable rules here are:
// .group\:hover [__TAILWIND-APPLY-PLACEHOLDER__]
// [__TAILWIND-APPLY-PLACEHOLDER__]:hover
}
}
} Output should be: .group\:hover .foo {
.bar {
.baz {
opacity: .5;
}
}
}
.foo {
.bar {
.baz:hover {
font-weight: 700;
}
}
} Haven't thought through this bit in too much detail yet but another note for myself, think through what happens when people use |
This should be 95% fixed now (some really complex edge cases we don't handle yet but we will tackle soon). Going to close this but can capture the edge cases in a new issue. Will tag new patch release in a couple min here. |
@adamwathan one thing I just noticed when trying out
than in my vue component I have
resulting code just doesn't contain that !important:
without I tried to use
above tailwindcss in the config but that that just makes build fail also wanted to mention that it's not connected with purgeCSS since it was off |
Do you mind opening a new issue for that? I’m going to forget about it if it’s just sitting here in this closed issue. |
sure |
Describe the problem:
With the new applyComplexClasses if you put
@apply
the old way: inside a@screen
(media query) or a&:hover
(variant), the complier gets stuck (using postcss loader in webpack).Link to a minimal reproduction:
This css makes the compiler gets stuck (apply content can be anything):
I know the I should use the new way to
@apply md:w-2/6
and@apply hover:text-white
, but for backward compatibility could be good fixing this bug, or at least give an error in the compiler, right now it just gets stuck compiling.The text was updated successfully, but these errors were encountered: