-
Notifications
You must be signed in to change notification settings - Fork 27.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next 13 + experimental app dir + Tailwind hot-reload of classes doesn't work #43878
Comments
I got the same error, it only works with classes already defined somewhere else. |
Same error on |
Related issue here #43396 (comment) |
I'm on I up- and downgraded between different next.js versions and there is a difference between |
I have an issue as well with 13.0.6, hot reload often "loading" endless with a small project. |
My problem looks like solved. I added this into the tailwind.config (excludes node_modules from purge):
P.S.: Not sure if this solved my problem, other candidate was switching off the windows firewall. |
Unfortunately @teddybee's workaround didn't work for me, it may be because I'm in a pnpm monorepo Still broken on latest canary |
Not fixed in v13.0.7-canary.4 |
Facing the same issue. The only workaround I've found is to downgrade your next version to |
I can confirm the issue. Happens specifically on |
We land a fix in 13.0.8-canary.0. Could you upgrade to to see if the hmr is fixed for you? |
Working as expected now on |
doesn't seem to work for me when upgrading to |
@asheikho99 could you provide a reproduction, will be easier to investigate 🙏 thanks |
Here is a GIF shows the exact issue. Notice how it's working fine until couple changes then it stops working, I would have to manually refresh to see changes. ❯ To reproduce: ❯ Using: ❯ npx next info
|
Running under WSL on Windows 10, clean yarn install doesn't work for me. New classes are not compiled in when saved.
|
I fixed the problem for me by adding a proper HTML structure to my RootLayout, like this: Before (app/layout.tsx): import "../styles/globals.scss";
import Nav from "./Nav";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<>
<Nav />
<main>{children}</main>
</>
);
} After(app/layout.tsx): import "../styles/globals.scss";
import Nav from "./Nav";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html>
<head></head>
<body>
<header>
<Nav />
</header>
<main>{children}</main>
</body>
</html>
);
} |
Not fixed in 13.0.7 |
@asheikho99 I tried your reproduction on a windows VM it works for me. I feel it's another issue with windows specific based on the reports after reopening. I'd like to close this for now since it's fixed for the original issue. We can track the windows one in the new issue. |
@leerob I use In this repro, I modify the code of export default function About() {
return (
<div>
<div className="h-[100vh] text-red-600">Block 1</div>
<div className="h-96 text-blue-600">Block 2</div>
<div className="h-96 text-yellow-600">Block 3</div>
</div>
);
} nextjs-tailwindcss.mov |
The problem here is the layout structure, like @DerTyp876 mentioned. Making sure to have the proper structure solves the issue. |
@leerob You are editing app/page.tsx not pages/test.tsx. My problem happen only in the pages folder, not the app folder. |
The second video is |
@leerob I've tested your video and it seems that the colours have been generated somehow. If you try with a completely new colour like You'll see in this video that colours I've used previously are updated straight away but if I try a new colour like CleanShot.2023-01-18.at.12.22.30.mp4 |
As for me I couldn’t get it to work in neither pages, nor app directory, also didn’t matter whether I was using Turbopack or not. Edit: Looking at the console of Chrome and Firefox, both show „Reloading CSS chunk `_next/static/chunks/rsc/src_app_globals.css`“ but Chrome reflects the changes on the page, Firefox doesn’t. Firefox also doesn’t show the new classes in the styles tab. Note that the console message only seems to appear when a tailwindcss class is changed/added, not when an element is changed/added, or a non-tailwind class is added/edited. |
Tailwind Integration is indeed buggy in Next 13. Both Pages and app, there are some issues. Recently, none of my styles was affecting, but finally added a For Next.js team, Please add a |
I've noticed that sometimes it will start working in safari if I totally quit and restart the browser (not just hard refresh or close the page). |
Confirmed this fixed it for me using Next 13.1.3 on macos. My layout structure is fine too. Trying the same stuff in Chrome / Safari hot-reloads completely fine and as expected. So it looks like I'll be using Chrome until this resolves itself. Edit: I will stick with Firefox; it's the only non-shady browser out there. |
I see this failure on MacOS using Next 13.1.4, so still not fixed. FIXED: I was using the app folder, but the tailwind config only had the pages directory configured. Added the app directory and it works again. |
Hy, I am also facing this issue. I am am using nextjs v13.1.5 (also same issue on 13.1.4). On save, classes in browser do get changed but for them to take effect browser needs to be refreshed. But when use a previously class that took effect. Styles work without manually refreshing. I tested on firefox and brave. With brave it works fine. So i think issue is only with firefox. In the video when i switch 'p-20' to 'p-10' (which is previously used class that took effect on refresh) ui changes without refreshing the browser. But when I change 'p-10' to 'p-24' (which is not used previously) and hit save, class in browser console change but ui does not change. Then i refresh and 'p-24' takes effect. My guess is that styles are not being generated by tailwind on save. ( its just a guess, i dont know anything) |
The issue does exist on But I would also like to confirm the issue DOES happen on Firefox and DOES NOT happen on Chromium. I'm using ubuntu but i dont think that matters. I inspected the requests on both browsers and it seems firefox isnt sending the css requests. See the screenshots below Another thing i noticed the request to
So my thought is that @SheryConcepts, styles are probably being generated just not being pulled on refresh, on firefox. Edit: Downgrading to 13.0.4 does eliminate the issue for me. |
This is happening on 13.1.5 for me in both the app dir and pages dir. Tailwind works but requires a hard refresh in Chrome, Brave, and Safari. |
Interesting, the issue might really be browser independent then. @matthewdavi But do you encounter the issue in pages directory when the appDir feature is disabled in next.config? |
I had problems with 13.1.4 and so on, tried almost everything in this thread but still didn't work. But upgrading to canary 13.1.6 fixed it for me and it works on Firefox and Chrome using Windows. |
@vanquishkuso Are you saying this issue was fixed for you after you upgraded to Next |
Tailwind classes don't work, i am on nextjs |
@ngimdock I was testing today the latest version of NEXTJS creating a project from scratch, I did the configuration of the tailwindcss beta documentation with next 13 and the styles were not working. And it was because I put in the installation "use /src" in the project. Then looking for the error in stackoverflow, I noticed that when copying/pasting the tailwind.config.js, I forgot to change the path of the content. I feel SO Stup.... XD Source: Stackoverflow Comment |
Thanks for your sharing @IsraelOgas it solve my problem and i am feeling so stup** too |
@laneme I did a from scratch installation with canary, didn't upgrade from an earlier version. If I recall I installed Tailwind first as well as mentioned in this thread. Maybe you can try cloning my test repo portfolio and see if it works? |
@vanquishkuso Thank you for following up. I assume you mean this repo https://github.com/vanquishkuso/portfolio I cloned it and the issue is still there. Feels weird. I even quickly booted into a windows machine, just to be sure, installed node The issue was even severe in windows. On linux, styles updated if i just reloaded the page. And worked fine on chromium. Not on windows, had to restart the next dev server for the classnames to be effective. Very weird :/ I'll leave my versions for others Windows: npm |
Here to confirm this is still an issue in Works in Chrome/chromium, doesn't work in Firefox (both macos). |
So, I looked into it more. Firefox does not reload a css file by the same name if you add it to the NextJS is using MiniCssExtractPlugin (see here). |
Here is a potential fix (will fix ordering issue that may exist in addDir that did not exist elsewhere: Search you node_modules for
The whole section will then look like this:
Then [Edit: BTW, probably don't need to ignoreOrder as my insert preserves the order. Also, the code is not ES5 in case someone from Next is looking at this -- the code gets turned into a string and is not transpiled.] |
Hi all, we are tracking the issue here instead: #43396 (comment). |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
❯ npx next info
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue
https://github.com/vercel/app-playground
To Reproduce
/streaming
Product.tsx
and edit a class with a width classw-*
(go to line 75)w-1/3
forw-6/12
save and wait for hot-reload (don't manually refresh the page)w-10/12
, wait for hot-reload. Same result as above.w-6/12
and manually reload, you will see your class now (and it seems to be caching this class now)w-6/12
won't fail anymore because it seems to be cached now somehowDescribe the Bug
Hot reloading of Tailwind CSS when you change classes in your code doesn't work.
Only works after you apply a new class and manually reload the page.
Bug in action:
![bug](https://user-images.githubusercontent.com/364003/206681426-b3c4363f-94ab-470f-9a39-b83d16d4d08b.gif)
Expected Behavior
Swapping Tailwind classes from elements should work when hot-reloading.
Which browser are you using? (if relevant)
Chrome 108.0.5359.98 (Official Build) (x86_64)
How are you deploying your application? (if relevant)
Locally (npm run dev)
The text was updated successfully, but these errors were encountered: