-
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Bubbling not working as expected #81
Comments
Maybe this option will help you https://github.com/postcss/postcss-nested#bubble |
No, that's what I'm using at the moment. The problem seems to be that at-rules children won't we bubbled. It seems to be coded that way. |
OK. Can you show the expected output? Sorry, CSS example is too long, it is hard to me to understand it. |
Yea sure, sorry! Input: .class {
@screen xl { /* 'screen' is added to the bubble option of postcss-nested */
@apply w-1/3; /* I want this to behave like a normal css rule */
width: calc(100% / 3); /* Like this */
}
} expected output: @screen xl {
.class {
@apply w-1/3;
width: calc(100% / 3);
}
} actual output: @screen xl {
.class {
width: calc(100% / 3);
}
@apply w-1/3; /* It doesn't get nested inside the selector */
} |
And what are your |
|
Sorry. Still had no time to fix it. Will try to do it on this weekend. |
No worries man! It's open source, I could do it myself if it was blocking :-D. Besides It looks like it works like this by design, so there must be use cases where this behaviour is desired :-) |
@Windvis the solution is: const cssNested = require('postcss-nested')
mix.postCss('resources/css/app.css', 'public/css', [
tailwindcss('tailwind.js'),
cssNested({ bubble: ['screen'] }),
]) call |
From @ai comments in the I have tried the following patch: diff --git a/index.js b/index.js
index d933ad1e91dd..05ea9d9b1206 100644
--- a/index.js
+++ b/index.js
@@ -190,7 +190,7 @@ module.exports = (opts = {}) => {
return {
postcssPlugin: 'postcss-nested',
- Once (root, { Rule }) {
+ AtRule (root, { Rule }) {
function process (node) {
node.each(child => {
if (child.type === 'rule') {
@@ -201,7 +201,10 @@ module.exports = (opts = {}) => {
})
}
process(root)
- }
+ },
+ Rule (root, { Rule }) {
+ processRule(root, bubble, unwrap, preserveEmpty, Rule)
+ },
}
}
module.exports.postcss = true However I get the following error when I build:
If I comment out the following line in the Then it builds but I have many nested |
Yeap, that changes are not enough. We need to debug and change the origin functions. |
Can you try 5.0.6 release. The bug may be fixed by @bsak-shell in #137 |
Hey there!
I'm experimenting with a new PostCSS setup based on postcss-nested and Tailwind.
Tailwind has a set of @rules which I want to let play nice with postcss-nested. More specifically the @screen and @variants rules.
I added both to the
bubble
option of postcss-nested.I'm trying to transform the following code:
And this is the result (before Tailwind does its thing):
The @apply rules (which Tailwind uses to "mixin" styles) don't get nested in the bubbled selector as classic css rules do.
Any idea what could be causing this?
The text was updated successfully, but these errors were encountered: