Next.js Discord

Discord Forum

Tailwindcss randomly not being applied

Answered
European anchovy posted this in #help-forum
Open in Discord
European anchovyOP
I have no idea what is going on. Please help me. I literally worked on a twitter clone project sunday. This is how it looked like. Today I wanted to continue my work and now the entire UI is broken. I changed nothing in the code... could this be because I had nexjs: latest ? I was on version 13.5.3 before.
Answered by not-milo.tsx
Oh, yeah... You have to add this to your configuration:
 module.exports = {
   content: [
     './app/**/*.{js,ts,jsx,tsx,mdx}',
+    './components/**/*.{js,ts,jsx,tsx,mdx}',
   ],
   // rest of the configuration
 }
View full answer

32 Replies

European anchovyOP
the first image is how it looked sunday. and the one on the right is how it looks now...everything is broken...nothing in the code changed. it seems like tailwind classes are randomly not being applied.
Are you sure you didn't change anything int the code? Not even a package update of some kind?
European anchovyOP
Nextjs did update. Maybe supabase too. Nothing else I think....
I could be a package of some sort because I literally changed nothing...
Also something very weird. I have a component to show the tweets in the middle. I copied all the code from that component and pasted it directly in the home page.tsx. it fixed some things but the top home header was still broken. I REVERTED these changed but it looked the same. So basically it looked like it should on sunday, but the home header was broken and the tweets didnt have the hover effects. So those were broken too.
How can it randomly work then I change the code and rever the changes so basically it's the same, but it looks different
Have you tried deleting your .next folder and rebuilding the app from scratch?
European anchovyOP
No
This looks like an issue with your content entry for tailwind's configuration, but if you didn't change it then it ight be some kind of weird build artifact...
@European anchovy No
Try it
European anchovyOP
So do I just delete the .next app and then what ?
I tried delete the node modules and reinstalling and even downgrading to next 13.5.3...no fix
I am afk rn...I will try deleting the .next folder. But I did try to clone the git repo again and it didnt work either....
So it actually makes no sense....
After you delete the .next folder run npm run build and npm run start and see if the issue persists. (if you're using pnpm or yarn just remove the run keyword from the commands)
European anchovyOP
I deleted the entire dir and cloned the git repo again before leaving from home....and it didnt work
I use npm
Ok, if you can please send a screenshot of your tailwind configuration and project structure
European anchovyOP
Oh, yeah... You have to add this to your configuration:
 module.exports = {
   content: [
     './app/**/*.{js,ts,jsx,tsx,mdx}',
+    './components/**/*.{js,ts,jsx,tsx,mdx}',
   ],
   // rest of the configuration
 }
Answer
European anchovyOP
But it worked on sunday....
I will try it asap
Thanks a lot
@European anchovy But it worked on sunday....
Maybe you moved your components folder from ./app/components out to ./components...
European anchovyOP
Could be...but the weird thing is that it looked fine
@European anchovy Thanks a lot
No problem ✌🏻
Let me know if this solves it
European anchovyOP
I mean i did move it, but it looked ok
Thank you so much. Im afk but will fix it asap
@European anchovy I mean i did move it, but it looked ok
Yeah, until a full rebuild is done you might not notice some errors straight away cause the old files might still exist inside .next
European anchovyOP
Oh...ok. that is so weird but good to know
European anchovyOP
@not-milo.tsx it worked. Thank you so much 🙂 really appreciate it
Great! ✨