2

I'm trying to use nested declarations in Tailwind, so, in their docs they show postcss.config.js using require() from CommonJS:

// postcss.config.js
module.exports = {
  plugins: [
    require('postcss-import'),
    require('tailwindcss/nesting'),
    require('tailwindcss'),
    require('autoprefixer'),
  ]
}

I need the same behavior, but in another format, not using the require() format, example:

// postcss.config.js
module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
  }
}

1 Answer 1

4

You need to install postcss-import via npm/yarn and then change your postcss.config.js to:

module.exports = {
    plugins: {
        'postcss-import': {},
        'tailwindcss/nesting': {},
        tailwindcss: {},
        autoprefixer: {},
    }
}

Also: When you use tailwindcss to transpile your CSS make sure you have the --postcss flag enabled.

Sign up to request clarification or add additional context in comments.

3 Comments

what do you mean we should update start script by adding --postcss:true like that ? Thanks
TY man, after --postcss works ;)
same here, adding --postcss to "watch": "npx tailwindcss -i ./tailwind.css -o ./_SITE/_/css/tw.css --watch --postcss", in package.json fixed tailwind not processing nested rules. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.