Skip to content

[Bug]: PostCSS error in @modern-js/plugin-tailwindcss #6925

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

Closed
harihar-nautiyal opened this issue Mar 11, 2025 · 2 comments
Closed

[Bug]: PostCSS error in @modern-js/plugin-tailwindcss #6925

harihar-nautiyal opened this issue Mar 11, 2025 · 2 comments
Labels
💉 bug Something isn't working

Comments

@harihar-nautiyal
Copy link

Version

System:
    OS: Linux 6.13 Fedora Linux 41 (Workstation Edition)
    CPU: (48) x64 AMD Ryzen Threadripper PRO 7965WX
    Memory: 20.66 GB / 27.29 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Browsers:
    Chrome: canary
  npmPackages:
    @modern-js/app-tools: 2.65.3 => 2.65.3 
    @modern-js/plugin-tailwindcss: ^2.65.3 => 2.65.3 
    @modern-js/runtime: 2.65.3 => 2.65.3 
    @modern-js/tsconfig: 2.65.3 => 2.65.3

Details

I recently initialized my first Modern.js app and wanted to install Tailwind CSS. I found the documentation for installing Tailwind CSS in Modern.js here. I followed the instructions correctly, but when I started the app, I encountered a PostCSS error.


> [email protected] dev
> modern dev

  Modern.js Framework v2.65.3

error   Error: It looks like you're trying to use `tailwindcss` directly as a PostCSS plugin. The PostCSS plugin has moved to a separate package, so to continue using Tailwind CSS with PostCSS you'll need to install `@tailwindcss/postcss` and update your PostCSS configuration.
    at Re (/home/hariharnautiyal/tests/m-tail/node_modules/.pnpm/[email protected]/node_modules/tailwindcss/dist/lib.js:33:1723)
    at postcss (/home/hariharnautiyal/tests/m-tail/node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@modern-js/plugin-tailwindcss/dist/cjs/cli.js:92:59)
    at reduceConfigsWithContext (/home/hariharnautiyal/tests/m-tail/node_modules/.pnpm/@[email protected]/node_modules/@rsbuild/core/dist/index.cjs:2208:168)
    at /home/hariharnautiyal/tests/m-tail/node_modules/.pnpm/@[email protected]/node_modules/@rsbuild/core/dist/index.cjs:2208:259
    at Array.reduce (<anonymous>)
    at reduceConfigsWithContext (/home/hariharnautiyal/tests/m-tail/node_modules/.pnpm/@[email protected]/node_modules/@rsbuild/core/dist/index.cjs:2208:233)
    at getPostcssLoaderOptions (/home/hariharnautiyal/tests/m-tail/node_modules/.pnpm/@[email protected]/node_modules/@rsbuild/core/dist/index.cjs:2285:28)
    at Object.handler (/home/hariharnautiyal/tests/m-tail/node_modules/.pnpm/@[email protected]/node_modules/@rsbuild/core/dist/index.cjs:2362:56)
    at Object.callChain (/home/hariharnautiyal/tests/m-tail/node_modules/.pnpm/@[email protected]/node_modules/@rsbuild/core/dist/index.cjs:1455:34)
    at modifyBundlerChain (/home/hariharnautiyal/tests/m-tail/node_modules/.pnpm/@[email protected]/node_modules/@rsbuild/core/dist/index.cjs:1892:94)

Here is my configuration file:

import { appTools, defineConfig } from "@modern-js/app-tools";
import { tailwindcssPlugin } from "@modern-js/plugin-tailwindcss";

// https://modernjs.dev/en/configure/app/usage
export default defineConfig({
  runtime: {
    router: true,
  },
  plugins: [
    appTools({
      bundler: "rspack", // Set to 'webpack' to enable webpack
    }),
    tailwindcssPlugin(),
  ],
});

Here is my tailwind configuration file:

import type { Config } from "tailwindcss";

export default {
  content: ["./src/**/*.{js,jsx,ts,tsx}"],
} as Config;

Here is my index.css file:

@tailwind base;
@tailwind components;
@tailwind utilities;

---

Also how to configure shadcn and tailwind in modern.js without these plugins.

Reproduce link

https://youtu.be/Pm9kjINagT0

Reproduce Steps

  1. Initialize new app
  2. Install @modern-js/plugin-tailwindcss
  3. Configure tailwind.config.js
  4. Configure index.css
  5. Run
@harihar-nautiyal harihar-nautiyal added the 💉 bug Something isn't working label Mar 11, 2025
@zllkjc
Copy link
Member

zllkjc commented Mar 12, 2025

maybe related to #6756

@zllkjc zllkjc closed this as completed Apr 27, 2025
@zllkjc
Copy link
Member

zllkjc commented Apr 27, 2025

Due to the lack of response for a long time, this issue will be temporarily closed. If there are still any questions, please feel free to reopen this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💉 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants