I wanted to use Tailwind and SCSS on my Nuxt site, but I noticed that the only way to make it work is if the file where I put @import
is a CSS file; it doesn't work in an SCSS file.
I don't understand why, since my SCSS code seems to work otherwise. Does anyone know why?
My dependencies:
{
"dependencies": {
"@nuxt/eslint": "1.9.0",
"@nuxt/fonts": "0.11.4",
"@nuxt/icon": "2.0.0",
"@nuxt/image": "1.11.0",
"@nuxt/scripts": "0.11.13",
"@nuxtjs/i18n": "10.0.6",
"@tailwindcss/vite": "^4.1.12",
"@unhead/vue": "^2.0.14",
"daisyui": "^5.1.3",
"eslint": "^9.34.0",
"nuxt": "^4.0.3",
"tailwindcss": "^4.1.12",
"vue": "^3.5.20",
"vue-router": "^4.5.1"
},
"devDependencies": {
"sass": "^1.91.0"
}
}
nuxt.config.ts
import tailwindcss from "@tailwindcss/vite";
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
compatibilityDate: "2025-07-15",
devtools: { enabled: true },
css: ["~/assets/style/main.css"],
modules: [
"@nuxt/eslint",
"@nuxt/fonts",
"@nuxt/icon",
"@nuxt/image",
"@nuxt/scripts",
"@nuxtjs/i18n",
],
vite: { plugins: [tailwindcss()] },
i18n: {
defaultLocale: "en",
locales: [
{ code: "en", name: "English", file: "en.json" },
{ code: "it", name: "Italiano", file: "it.json" },
],
},
});
Starting from TailwindCSS v4, preprocessors are no longer officially supported - it aims to function as its own preprocessor, with LightningCSS working under the hood to make this possible.
You can use TailwindCSS and SCSS in parallel, but not together. For example:
./assets/styles/scss/main.scss
@use "./tailwind.css";
./assets/styles/scss/tailwind.css
@import "tailwindcss"; @theme { --color-neutral-0: #111; }
But the official recommendation is to drop it entirely, and its compatibility issues will not be given priority in the future:
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 Robin Malfait: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.
You can read about that in our compatibility guide but the short answer is that we do not support SCSS files with the Vite plugin. If you really need it for some reason, you can try to build your own SCSS implementation with the PostCSS plugin and by controlling the execution order but both SCSS and Tailwind CSS are pre-processors that extend CSS and cause a conflict in some areas, so that's not something that we can support unfortunately.
If you want to use TailwindCSS with SCSS completely free of issues, I recommend reverting to v3. For this, you need to perform a version-specific installation and follow the old documentation:
npm uninstall @tailwindcss/vite
npm install tailwindcss@3 postcss autoprefixer