-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
order of styles #1836
Comments
I am also running into a similar issue. I'm using |
I'm pretty sure the order of the injected css follows the order of your plugin declarations. Try moving that around. |
I kinda solved my problem. The thing is I was importing a standard css file, e.g. import "semantic-ui-css/lib/style.css" (or what not) in my layout component. Maybe it was just me being used to webpack and extract text plugin but those "css plain imports" I had in previous react/webpack projects just put into css files that I was in charge of when and where they got imported in my html (e.g. a vendor.css or something). What struck me here since I was building public facing site was that could just use semantic-ui css from their CDN and just do a plain old <link ... /> in html.js which of course works just as fine. And then I could use my styled-comps in the way I wanted to. So...maybe a bad design/thinking on my part perhaps....dunno?? Maybe there's a question/discussion in here somewhere on where plain import "somestyle.css" should really end up the outputted html...?? |
Same thing here - importing require('normalize.css')
require('prismjs/themes/prism-twilight.css')
import './index.sass'; but the output css has |
Hey I just ran into a bug with the order of the styles using I'm importing
In the
The You can check this in this project: I also deployed the sample project to Netlify: Edit: After following this advice #1994 (comment) from @KyleAMathews my site is working 😄. I would like to know why we are importing the default CSS after the css-in-js instead of reversing it by default? The error that appears only in production seems to be related to Webpack. More info in this issue: webpack/webpack#215 (comment) |
Seeing this issue too. Followed the advice and switch...
But still seeing the css output in the wrong order. My styled components appear first then the sass imports are appearing last which ends up with normalize.css overriding everything. |
I'm having a similar problem. Is there any known fix? |
I worked around this issue just now by installing There was only a critical order for two of my stylesheets -- normalize.css and my global.css stylesheet. The above plugins allow me to move the import of the normalize.css stylesheet into the top of my global.css one. |
I have just discovered this issue too but in a slightly different scenario. My project is based off the default starter and in the Helmet tag of layout.js, I added a style sheet like so
When using develop, the stylesheet ends up as the last stylesheet in the head, which has consequences of not showing the correct styles (In this case the font height). When I build then it's put at the top and everything works fine. I haven't tried it but I assume I can switch to a non CDN based bootstrap css and then import it but I'd prefer not to. |
Any news on this issue? I have just built a site with bootstrap that imports the bootstrap css where needed (layouts and pages) and production builds are rearranging the import order in the final CSS so bootstrap override what should be MY overrides. |
I'm having a similar issue at #9908 |
In case it helps someone, here is what happened to me. I have a single import in my layout to an @import "~normalize.css/normalize.css";
@import "./base.css"; The tilde I worked around this in Gatsby v1 by importing @import "../../node_modules/etc." In Gatsby v2, @tremby's solution with @import "normalize.css";
@import "./base.css"; Only problem left for me is that Gatsby still seems to inline some "critical" components' styles (e.g. header/footer) before |
You probably meant |
Hmm, no, just |
Oh, I thought |
I ran into this issue as well, I solved it by importing my main CSS file in |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! Thanks for being a part of the Gatsby community! 💪💜 |
Have not tested this in some time, but last I checked it was still an issue. Bumping it to keep it from being auto-closed by @gatsbot |
I published a fix for this where we're not code splitting CSS which should solve the problems y'all are facing. Please update to [email protected] and lemme know if you're still having troubles! |
This fixes the typography.js problem #12295 |
Hey,
thanks for a great library...loving it!
However, got a question.
I'm building site with styled-components and semantic-ui (react). The problem I'm facing is that I'm importing the semantic-ui css in my layouts/index.js file and that's all working great but when I then define some styled components that sometimes take a component from semantic-ui and alters it my styled-component styles get appended before the semantic-ui css in the head tag, thus they take precedence over the styled component ones.
Is there something I can do about that or am I going at this in the wrong way somehow?
The text was updated successfully, but these errors were encountered: