-
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
[v2] CSS (via Sass) inlined in different locations between develop and build #6302
Comments
I’m experiencing the same issue on my site. Ultimately what I had to do to resolve it was to create a custom html.js and move the Typography.js styles to the top. I’m not sure how this could be resolved in Gatsby core. Should Gatsby core manage the sort order of head elements? Should their be a priority for setHeadCompoments? It’s kind of an ugly problem. |
There's probably a better way to handle this, I just wanted it fixed. Here's the commit where I fixed the issue: octalmage/jason.stallin.gs@90445ca#diff-58826c9c508b82875d8f9a9872d19e2dR1 |
@octalmage fyi, I upgraded to beta.42 (going off memory here, was newest ~8 hours ago). The upgrade fixed this issue, but now I have a FOUC. I was waiting to post until I had updated the repro, but this feels like it is related to #6211 which I've been keeping an eye on. I suspect it's an issue with how core is interacting with typography. |
@jbolda I was having FOUC too, which ended up still being related to Typography loading after everything else. The fix I posted above resolved it, and now I'm happy! It's a hack though, so it would be great if this get fixed in Gatsby core. |
FYI, I'm working on a new API to allow users to fix this: |
Alright, now that my PR has been merged I'm going to look at adding a fix to the Typography plugin. |
This seems to be a problem with all CSS. Development and production order the css in different ways, even with regular import's of css files. Try importing bootstrap and some other css file for a layout or component. It'll come out correctly in develop but possibly not in production. There really needs to be some sort of standardised solution to CSS ordering within Gatsby. Is there any reason why it can't just keep the order of the import statements? |
Yeah I wonder if this could be the issue:
|
Yeahj i think we need to do something smarter for the inlining...like look what html-plugin is doing: https://github.com/jantimon/html-webpack-plugin/blob/master/lib/chunksorter.js |
@jquense woah cool! Yeah, that definitely seems useful. It wouldn't solve the typography.js issue though as that's added by gatsby-plugin-typography which doesn't run through webpack. |
i was thinking of my css woes :P ;) |
Fixed the link in my comment, Gatsby goes through and sorts preloaded items to the top. This could be causing styles to be loaded in different orders between development and production.
|
This bug popped up in https://github.com/mjordancodes/portfolio/tree/link-typography-problem with Typography.js inlining in different order and introducing mystery bugs for @mjordancodes. |
Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open! |
Description
Using
typography.js
andgatsby-plugin-sass
(and associated libraries of each), the css is "blobbed" aftertypography
in develop and inlined beforetypography
in build. This means the look of the website changes from develop to build. Images below (obviously more drastic with more css being moved around).develop:
build:
Steps to reproduce
Super basic repro available here.
Expected result
The look website end result in v1 matched what I am seeing in develop in v2 so I would expect that
typography
would be listed in the<head>
before the inlined css.Actual result
The opposite of expected.
Environment
Current environment below, but tested with both yarn and npm on Windows locally. I noticed the issue after a Netlify deploy preview (so Linux and Yarn).
File contents (if changed)
See repro repo. Essentially
my-hello-world
with both plugins added.The text was updated successfully, but these errors were encountered: