The issue is that Tailwind’s @tailwind and @apply directives are not processed by SCSS (.scss) files—they only work in plain CSS files (.css or .pcss). SCSS preprocessors do not understand Tailwind’s custom directives, so they are ignored or cause errors.
How to fix:
-
Use a plain CSS file for Tailwind directives and utilities.
Move your Tailwind-related code to app.css instead of app.scss.
-
If you need to write custom CSS with Tailwind, use PostCSS syntax, not SCSS.
Example:
Your resources/css/app.css should look like:
@tailwind base;
@tailwind components;
@tailwind utilities;
.dale {
@apply text-red-200 text-2xl;
}
Update your vite.config.js input:
You only need to include app.css (not both app.css and app.scss for Tailwind):
input: [
'resources/css/app.css',
'resources/js/app.js',
// ...other files
],
In your Blade file:
@vite(['resources/css/app.css', 'resources/js/app.js'])
If you need to use SCSS for other custom styles:
- Keep Tailwind stuff in
app.css.
- Import your compiled SCSS file after Tailwind’s CSS if you want to override Tailwind styles.
Summary:
Tailwind’s @tailwind and @apply do not work in .scss files. Use a plain CSS file for Tailwind, and only use SCSS for non-Tailwind custom styles.
References: