Migrated from CRA to Vite, Tailwind CSS error: "Cannot apply unknown utility class: sm:text-lg" #17858
Unanswered
weeeellllll
asked this question in
Help
Replies: 1 comment 4 replies
-
Does this CSS file have As an aside, Adam Wathan (creator of Tailwind) does seem to advocate avoiding |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone, I recently migrated my project from Create React App (CRA) to Vite, and I’m running into an issue with Tailwind CSS. After making all the changes for the migration, I’m getting the following error:
Error: Cannot apply unknown utility class: sm:text-lg
The error seems to originate from my custom CSS classes where I’m using @apply to compose Tailwind utilities. Here’s the relevant code:
Tailwind no longer recognizes utility classes (especially responsive ones like sm:text-lg), and I can’t run my project properly. If I remove @apply and write pure CSS instead, the error goes away, but I lose all the benefits of Tailwind, and it messes up my project’s styling. I’m new to front-end development, so feel free to point out anything obvious I might have missed—any help is appreciated!
Here’s what I’ve tried so far:
Migrated the project to Vite following the official guide.
Set up Tailwind as per the Tailwind CSS Vite guide.
How can I fix this issue and get Tailwind working properly with Vite?
Remember, when I used CRA all this worked perfectly
Beta Was this translation helpful? Give feedback.
All reactions