Skip to content
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

tailwindcss/nesting used with postcss-nesting breaks some postcss plugins #7234

Closed
lubomirblazekcz opened this issue Jan 27, 2022 · 9 comments · Fixed by #7563
Closed

tailwindcss/nesting used with postcss-nesting breaks some postcss plugins #7234

lubomirblazekcz opened this issue Jan 27, 2022 · 9 comments · Fixed by #7563

Comments

@lubomirblazekcz
Copy link
Contributor

What version of Tailwind CSS are you using?

v3.0.17

What build tool (or framework if it abstracts the build tool) are you using?

[email protected]

What version of Node.js are you using?

For example: v17.1.0

What operating system are you using?

MacOS

Describe your issue

tailwindcss/nesting used with postcss-nesting breaks some postcss plugins. In this example vite config cssHasPseudo is not working. Also another plugin that is not working is postcss-mixins

import tailwindcss from 'tailwindcss'
import tailwindcssNesting from 'tailwindcss/nesting'
import autoprefixer from 'autoprefixer'
import postcssImport from 'postcss-import'
import postcssNesting from 'postcss-nesting'
import cssHasPseudo from 'css-has-pseudo'
import postcssCustomMedia from 'postcss-custom-media'

export default {
    css: {
        postcss: {
            plugins: [postcssImport, tailwindcssNesting(postcssNesting), postcssCustomMedia, cssHasPseudo, tailwindcss, autoprefixer]
        }
    }
}
@thecrypticace
Copy link
Contributor

Could you provide a reproduction? It would help to see the versions of the plugins you have installed along with the whole of the setup.

@lubomirblazekcz
Copy link
Contributor Author

lubomirblazekcz commented Feb 1, 2022

Here is a repro, hope it helps (text should turn red). All plugins are latest versions

with tailwind (doesn't work) - https://stackblitz.com/edit/vitejs-vite-fv2tnq?file=style.pcss&terminal=dev
without tailwind (works) - https://stackblitz.com/edit/vitejs-vite-vbidlr?file=style.pcss&terminal=dev

@thecrypticace
Copy link
Contributor

thecrypticace commented Feb 7, 2022

Just to follow up here — I tracked down the issue last week and we are working with PostCSS on a fix. Thanks!

@j1mbl3s
Copy link

j1mbl3s commented Feb 9, 2022

postcss-inline-svg is also affected by this.
Mentioning in case someone else is looking to find the cause of their issue.

@JackieCheung
Copy link

"postcss-mixins": "^9.0.2"
"tailwindcss": "^3.0.23"

The problem still exists.

@JackieCheung
Copy link

A solution refers to https://giters.com/tailwindlabs/tailwindcss/issues/3931

plugins: [
  {
    postcssPlugin: 'postcss-mixins',
    Once(root, { result }) {
      return require('postcss')([require('postcss-mixins')]).process(
        root,
        result.opts
      )
    }
  },
  require('tailwindcss/nesting'),
  require('tailwindcss'),
  require('autoprefixer')
]

It must to wrap postcss-mixins by Once, I think it is not elegant enough.

@j1mbl3s
Copy link

j1mbl3s commented Apr 1, 2022

@JackieCheung The PR for this issue was merged on Feb 21. Tailwind v3.0.23 was released Feb 16.
It should be fixed in the next release.

@JackieCheung
Copy link

A solution refers to https://giters.com/tailwindlabs/tailwindcss/issues/3931

plugins: [
  {
    postcssPlugin: 'postcss-mixins',
    Once(root, { result }) {
      return require('postcss')([require('postcss-mixins')]).process(
        root,
        result.opts
      )
    }
  },
  require('tailwindcss/nesting'),
  require('tailwindcss'),
  require('autoprefixer')
]

It must to wrap postcss-mixins by Once, I think it is not elegant enough.

The problem still exists in v3.0.24

@thecrypticace
Copy link
Contributor

Could you open this as a separate issue please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants