DEV Community

Sergiu Mironescu
Sergiu Mironescu

Posted on

2 1

Nested CSS was detected, but CSS nesting has not been configured correctly - Astro

Hello,

After following the steps from the Atros Docs, I get the error on the console (check screenshots).
Seems that somehow PostCSS config has some conflicts with Tailwind, following the Astro Doc.

MacOSX Ventura 13.5.1
VSCode
"astro": "^3.1.0",
package.json:



{
  "name": "sm_astro",
  "type": "module",
  "version": "0.0.1",
  "browserslist": [
    "defaults"
  ],
  "scripts": {
    "dev": "bun --bun astro dev",
    "start": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
  "dependencies": {
    "@astrojs/partytown": "^2.0.0",
    "@astrojs/sitemap": "^3.0.0",
    "@astrojs/tailwind": "^5.0.0",
    "@typescript-eslint/parser": "^6.7.0",
    "astro": "^3.1.0",
    "astro-icon": "^0.8.1",
    "autoprefixer": "^10.4.15",
    "eslint-plugin-astro": "^0.29.0",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "tailwindcss": "^3.3.3"
  },
  "devDependencies": {
    "bun-types": "^1.0.2",
    "eslint": "^8.49.0"
  }
}


Enter fullscreen mode Exit fullscreen mode

Changed from:



const autoprefixer = require('autoprefixer');

module.exports = {
   plugins: [
      autoprefixer(),
   ]
};


Enter fullscreen mode Exit fullscreen mode

To:



module.exports = {
   plugins: {
      'tailwindcss/nesting': {}, <--- Needs this
      tailwindcss: {},
      autoprefixer: {},
   }
};


Enter fullscreen mode Exit fullscreen mode

You can check the reproducible error here and the fix commented on postcss.confic.jsc

https://stackblitz.com/edit/github-elgzfe-pwwt3m?file=src%2Flayouts%2FLayout.astro,postcss.config.cjs,package.json

Error console:
Image description

Fix:
Image description

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay