Tailwind Plugin Changes
Modern.js 3.0 recommends integrating Tailwind CSS through Rsbuild's native approach, no longer relying on the @modern-js/plugin-tailwindcss plugin, to fully utilize Rsbuild's more flexible configuration capabilities and better build experience.
Migration Steps
The migration operations in this section are only required if the project uses the @modern-js/plugin-tailwindcss plugin and the tailwindcss version is v2 or v3.
1. Remove Old Plugin
Remove the @modern-js/plugin-tailwindcss dependency and configuration.
2.0 Version:
3.0 Version:
Also remove the @modern-js/plugin-tailwindcss dependency from package.json.
2. Configure PostCSS
Create or update the postcss.config.cjs file.
3. Tailwind CSS Configuration Migration
Single Configuration Case:
- If only configured in
tailwind.config.{ts,js}, no additional processing is needed - If only configured in
modern.config.ts, you need to migrate Tailwind-related configurations totailwind.config.{ts,js}
Dual Configuration Case:
If both tailwind.config.{ts,js} and modern.config.ts have configurations, you need to merge the configurations from both and migrate the merged configuration to tailwind.config.{ts,js}.
Special Directory Handling:
If the project has storybook or config/html directories, you need to add them to the content in tailwind.config.{ts,js}:
4. CSS Style Import
Change the CSS import method to the @tailwind directive approach.
2.0 Version:
3.0 Version: