How to configure TailwindCSS 4 with Angular and Vite? #17716
-
I have an Angular monorepo (application + libraries), built with Vite. My application is configured to use I installed
and imported tailwind in my css:
Running the build, no errors, and the generated css file contains a whole bunch of tailwind stuff. All good so far. I added a
Rebuild, still no errors. Running the app, I see the As a second test, I added some color definitions to
modify
Rebuild, still no colors. Both colors show up in a Clearly, something is missing or misconfigured, but I am scratching my head as to what it could possibly be. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You may need to use |
Beta Was this translation helpful? Give feedback.
-
I put together a minimal reproduction https://github.com/DarthRainbows/angular-tailwind-demo |
Beta Was this translation helpful? Give feedback.
Well, after further research, it seems the answer is that the Angular team decided that vite's role in their ecosystem is rather more limited than in other frameworks. It's not used in the build process at all. 😞 The vite.config.mts file is used for vitest only.
I'm going to explore getting the PostCSS pipeline up and running, or maybe converting over to Analog, as that replaces Angular's build system and supports the full vite ecosystem.
[edit] on further review, it looks like PostCSS isn't compatible with Angular 19 either, at least not with Nx.