-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fix inlined css in every single page. #369
Conversation
Fix for issue #366 SSR means "server side rendering". This fix is from a long github discussion about how broken including all css inline in the file is. (Especially since newer CSP guidelines say all css should be in a separate file.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, interesting catch, but if it's not running on our prod builds I'm not sure I see the reasoning, though I may be misreading this / misinterpreting the purpose.
In any case it does seem like one of the commenters had to check for a particular property's existence so marking as request changes at least for that; otherwise I'd be curious to tie this back to real-world repercussions also if we can
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a creative fix! Is it safe to say that the styles were duplicated (in-line) and external and this is now just pointing to the external stylesheet?
Yes. The gatsby build processes the files to produce static html output for deploying web pages. This hooks into it to fix an odd behavior in the gatsby sass processing plugin. |
This gatsby sass plugin hasn't been worked on in a long time and I'm confused why they closed this issue without fixing it. The real fix is to add a flag to the plugin to control this behavior, not have everyone stub their toe on it and then have to add custom code. |
Apologies for my misreading, clearly I have Friday Brain. Would be good to go with that extra check I think |
* Check el.props['data-href'] is valid * Add comment for production only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and good catch!
Fix for issue #366
Created a gatsby-ssr.js to manually remove the css styles embedded in the pages.
SSR means "server side rendering". This fix is from a long github discussion about how broken including all css inline in the file is.
The patch came from here: gatsbyjs/gatsby#1526 (comment)
But honestly, I can't believe there is no flag to control this behavior and the issue was marked "Closed" by the Gatsby folks the way it works now. Especially since newer CSP guidelines say all css should be in a separate file.
The outputted file size for main
index.html
This is for every single statically generated page.
I tested locally but we should watch for production build issues.