I have an Angular 19 app which uses SCSS and I have TailwindCSS 3.4.17 setup and it works.
Now I want to upgrade to TailwindCSS v4. I follow the official instructions to install it on Angular from here and I get errors.
[WARNING] Deprecation [plugin angular-sass]
src/styles/_tailwind.scss:1:8: 1 │ @import "tailwindcss"; ╵ ^
I can add @use "tailwindcss";
and that resolves that error. But I also get another error:
X [ERROR] Cannot apply unknown utility class: bg-gray-100 [plugin angular-sass]
node_modules/tailwindcss/dist/lib.js:17:296: 17 │ ...r,{onInvalidCandidate:x=>{throw new Error(`Cannot apply
unknown... ╵
So I removed all the @apply
declarations in my .scss
files, which cleared up the error, but then the tailwind.config.js
was not used.
The docs says:
JavaScript config files are still supported for backward compatibility, but they are no longer detected automatically in v4.
If you still need to use a JavaScript config file, you can load it explicitly using the @config directive:
CSS @config "../../tailwind.config.js";
So I added the @config
file to _tailwindcss.scss
which is included in my styles.scss
file, and I got errors again:
The plugin "angular-sass" was triggered by this import
angular:styles/global:styles:2:8: 2 │ @import 'src/styles.scss';
How am I supposed to configure Tailwind 4 to work with Angular 19 apps using Sass?
Note: Although my answer to How to upgrade TailwindCSS? is similar, the question is entirely different-only the conclusion is similar. Therefore, I'll leave the relevant parts of the documentation here. The key point is that starting from TailwindCSS v4, no preprocessor is needed anymore.
Sass, Less, and Stylus
Tailwind CSS v4.0 is a full-featured CSS build tool designed for a specific workflow, and is not designed to be used with CSS preprocessors like Sass, Less, or Stylus.
Think of Tailwind CSS itself as your preprocessor — you shouldn't use Tailwind with Sass for the same reason you wouldn't use Sass with Stylus.
Since Tailwind is designed for modern browsers, you actually don't need a preprocessor for things like nesting or variables, and Tailwind itself will do things like bundle your imports and add vendor prefixes.
Sorry for the inconvenience here, however right now we don't support migrating
.scss
or.less
files. Doing so would require us to be able to understand the scss/sass and less syntax to make changes. But even if we do that, Tailwind CSS v4 isn't really compatible with these files anyway.I would recommend to see if you can rename the file(s) to
.css
and try again. You might notice that sometimes people use scss for features such as nested css, which should just work already in Tailwind CSS v4 (and modern browsers). So there is a good chance that you might not need.scss
files at all.Again, sorry about the inconvenience here, but if you can migrate to normal
.css
files, then upgrading using the upgrade tool should just work.
tailwindlabs/tailwindcss
#15716 by RobinMalfait:Simply put, TailwindCSS v4 removes the need for Sass and other preprocessors. The TailwindCSS v4 ecosystem can independently provide the functionality that these preprocessors offered.