-
Notifications
You must be signed in to change notification settings - Fork 28.3k
CSS Module Hot Reloading Issue in Next.js Dev Mode #74749
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
Comments
Yep, this bug is also affecting my development environment on the latest version of Next.js (15.1.6). This is getting pretty annoying now, as every single CSS change results in this. Are there any workarounds that can be advised for the time being? |
For now, I haven't found a workaround, and it's getting pretty annoying to reload the page every time to apply changes. |
Totally agree. I'm confused as to why this has not had more attention to. Surely we cannot be the only two people having this issue?? |
Totally agree |
Also facing this issue, when modifying CSS files it doesn't reload correctly and throws
on a very barebones NextJS project. |
Are you using Turbopack? I was using Turbopack and removing this argument fixed the issue. Slightly annoying as Turbopack is supposed to be the faster option, but it works now. |
I'm facing the same issue in a nx monorepo setup since I updated to next 15 and start using turbopack.
@ColdDev which argument? |
In your package.json, if you have enabled Turbopack, I think the option will be within your options for |
Any updates on this issue? This works with me when Turbopack is disabled, however, I'm checking if there's a workaround to the issue while Turbopack is enabled. |
Same for me, not working with turbopack |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
nope the issue still |
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/unruffled-rui-xqj4ys
Issue Description:
I encountered an issue with CSS modules in my Next.js project when working in development mode. When I modify CSS properties in a CSS module and save the file, the styles do not update as expected in the browser. Instead, the following error is thrown in the console:
To Reproduce
1- Create a component that imports a CSS module:
import styles from './drawingcanvas.module.css';
2- Modify any CSS property in the CSS module while running the Next.js app in development mode (next dev).
3- Observe that the styles do not update in the browser, and the following error appears in the console:
Error: No link element found for chunk static/chunks/[...].css
4- Manually reload the page to apply the changes.
Current vs. Expected behavior
Expected Behavior:
CSS modules should hot reload, and the updated styles should be reflected in the browser without requiring a manual page reload.
Actual Behavior:
CSS changes in the module do not take effect, and the browser throws an error until the page is manually reloaded.
Workaround:
I resolved this issue by moving the CSS module import from the child component (Canvas component) to its parent component. I then passed the styles object as a prop to the child component. Example:
Parent Component:
Child Component:
This workaround fixed the issue, and the CSS changes hot-reloaded correctly in development mode. However, this introduces extra coupling between components and may not be an ideal solution.
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure, Developer Experience
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
The text was updated successfully, but these errors were encountered: