question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PostCSS nested not fully working

See original GitHub issue

Version

@nuxtjs/tailwindcss: v3.3.4 nuxt: v2.14.11

Reproduction Link

https://codesandbox.io/s/funny-hugle-1tyt8?file=/pages/index.vue

Steps to reproduce

I can’t append to class names.

I thought maybe I was doing something stupid but the example at postcss-nested doesnt work either.

.test {
  color: red;

  &_working {
    color: green;
  }

  & .nested {
    color: blue;
  }
}

What is Expected?

.test {
  color: red
}
.test_working {
    color: green;
}
.test .nested {
    color: blue;
}

What is actually happening?

.test {
  color: red
}
.test {
&_working {
    color: green;
}
}
.test .nested {
    color: blue;
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
Atinuxcommented, Dec 22, 2020

Hi @csheppard

Nuxt does not include postcss-nested by default, but it is really easy to add postcss plugins:

export default {
  build: {
    postcss: {
      plugins: {
        "postcss-nested": {}
      }
    }
  }
}

I updated your sandbox and it’s working: https://codesandbox.io/s/postcss-plugin-with-nuxt-tailwind-gyfo8?file=/nuxt.config.js:292-379

I also updated the documentation: https://tailwindcss.nuxtjs.org/examples/postcss-plugin

PS: sorry for the late answer

2reactions
gangsthubcommented, Aug 17, 2021

Ok, mystery solved 😅 https://github.com/nuxt-community/tailwindcss-module/releases/tag/v4.0.1

postcss-nesting is not the same as postcss-nested!

👀

So, instead of

.something {
  .somethingElse {
    color: green;
  }
}

You need to do:

.something {
  & .somethingElse {
    color: green;
  }
}

Which is compliant with https://drafts.csswg.org/css-nesting-1/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack - Postcss nesting not working used as suggested
The postcss.config.js is file loaded too. A screenshoot of the nested css in Chrome. enter image description here. Update. I set ...
Read more >
PostCSS nested not fully working · Issue #227 · nuxt ... - GitHub
PostCSS nested not fully working #227 ... Nuxt does not include postcss-nested by default, but it is really easy to add postcss plugins:....
Read more >
postcss-nested - npm
PostCSS plugin to unwrap nested rules like how Sass does it. Latest version: 6.0.0, last published: 3 months ago. Start using postcss-nested ......
Read more >
Writing Complex Classes Using @apply and Postcss-Nesting ...
In the example above, when we style our button by typing the TailwindCSS classes in inline, we can see that the code is...
Read more >
postcss-nested-ancestors | Yarn - Package Manager
When writing modular nested CSS, & current parent selector is often not enough. PostCSS Nested ancestors introduces ^& selector which let you reference...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found