-
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
Inconsistent loading order of CSS Modules + global CSS #10148
Comments
Please provide an example of the CSS files used. |
I've added a repository with minimum code that reproduces the issue https://github.com/nikkiselev/nextjs-css |
Once this issue is resolved, will there be any way to control the order of imported CSS files? A common desirable pattern might look like this:
|
CSS resets are global CSS, you can import them first in _app.js and it'll be loaded in that order.
|
@timneutkens Yes, I know. Sorry for not being clear. My question is more like: Are we able to import CSS, that would be loaded after CSS modules? |
You can't know the load order of CSS modules as they get added per-page. So there really is no "after" CSS modules state. |
@timneutkens I don't need to know the load order of CSS modules, I just need to find a way to include a global CSS at the very end of |
@liborvanek that is not possible, nor a use case we're currently interested in exploring. CSS will be loaded the order it's imported by the application. |
Any update on this issue? It's blocking my styles development using sass :/ |
What's the progress with this? I can't use the latest version on next because of this. I load two stylesheets in my project, bootstrap first then my styles. When I deploy to production the load order is reversed and all my styles are overwritten by bootstrap's... |
Shouldn't any CSS imported from CSS modules override global styles imported in the If I land on a page with a component that imports a CSS module, the global styles are added after the module's styles and overwrites its rules. But if I start the app and then go to the page with the component, the component's CSS gets added after the global styles and therefire overrides them. I would have thought the second version is the ideal behaviour. But it definitely shouldn't be inconsistent no? |
We have the same issue using the version 9.3.0 with SASS globals in _app and the CSS modules for single components |
I'm currently facing the same issue and it's kinda frustrating. It's stopping me from using next for now. 😕 |
Anyone have any ideas on how to resolve this? It's making it difficult to use Next as intended. |
(fixed, see below) |
If anyone on this thread is desperate for this fix, it is available in the |
@sparkertime this is awesome, thanks! |
@sparkertime many thanks for looking into it. Nonetheless, it's still broken when I import some components in |
@Joozty You'll probably want to open an issue specifically for ordering when importing modules from |
This is still not fixed yet, I still experienced with this issue in production mode in v9.4.4, |
after finding out what is the problem, I found that this issue because of mini-css plugin, I tried with my own version of webpack-config, after I added mini-css plugin to build on production this bug happened. |
9.4.4 did NOT fix the problem for me. However, @canary (currently 9.4.5-canary.7) DOES fix it in my case. |
same problem. I use reset.scss in _app.tsx and it does not work unless i reload page. Any solution now? |
I faced this problem too. In my _app.tsx, I imported single css file, which Before:
After:
|
This problem is still there, is there any plan on fixing it? |
Not really a fix, but a temporary solution is to directly copy and paste the files into one document to prevent Next from re-ordering them. I am on Next v9.5.2. This is preventing me from using next for future projects. Could you please advise when this will be fixed? Or is there a way to specify the order of imports for css and scss files? |
I'm locking this issue because the original issue was solved. If you are experiencing a bug, please open a new issue. |
Bug report
Describe the bug
I have a global CSS imported in
/pages/_app.js
andname.module.css
imported in a page. In production mode the CSS Module is loaded after the global CSS. In development mode, the CSS Module is loaded before the global CSS.To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Repository with code needed to reproduce the issue
Expected behavior
In development mode the global CSS should be loaded first and CSS Modules later on, the same as it works in production.
System information
Additional context
The page looks different in dev and production modes because of CSS overriding.
The text was updated successfully, but these errors were encountered: