-
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
Develop vs Build Styling very different [v 2.13.8 / 2.11.3 (cli) ] #22718
Comments
one more note ... <!DOCTYPE html><html><head><meta charSet="utf-8"/><meta http-equiv="x-ua-compatible" content="ie=edge"/><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/><style data-href="/styles.adf03b3d909d0a1f5515.css">@import url(https://fonts.googleapis.com/css?family=Raleway);html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress{vertical-align:baseline}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decorat the style sheet is being injected: <style data-href="/styles.adf03b3d909d0a1f5515.css"> but is being followed by the scss file contents now that i see it, its more likely my setup issue. i was confused initially as develop was working fine. any ideas how i troubleshoot sass & css modules for gatsby build? |
That should be fine. The browser doesn't do anything with |
Yes, please provide a minimal reproduction and we'll be able to take a look. Thanks for using Gatsby! 💜 |
hi there, thanks for the response. i was able to reproduce the same behaviour with a gatsby starter: https://github.com/kwixand/gatsby-starter-typescript-scss-modules same outcome observed: develop site looks fine but the production build (gatsby build) is completely off. the site builds but the styles rendered as text on the page. see screenshot the one change i made to the starter was to refer to a scss import from node_modules (just like my gatsby app) in the layout.tsx component: //import './Layout.scss'
import 'vital-css/sass/vital.sass' let me know if you still need a reproducible package. its basically the starter kit above plus the one line change. |
I just created a new site from that starter, and I don't see the problem 😕 |
That |
yes, its an npm package i added. that's the only difference to the starter },
"devDependencies": {
"node-sass": "^4.13.1",
"prettier": "^1.15.3",
"stylelint": "^9.9.0",
"stylelint-config-prettier": "^4.0.0",
"stylelint-config-recommended-scss": "^3.2.0",
"stylelint-config-standard": "^18.2.0",
"stylelint-order": "^2.0.0",
"stylelint-scss": "^3.4.2",
"tslint": "^5.12.0",
"tslint-config-prettier": "^1.17.0",
"tslint-react": "^3.6.0",
"vital-css": "^2.2.1"
} i see a difference between gatsby develop and gatsby build |
It's inlining an svg element from that |
There's actually 4 different inlined svg elements used as |
got it. thanks for the update. i don't need that css package. i'll replace it with something else. i thought that something was breaking in the gatsby build. so if its just related to the css library and how it inlines svgs then i'll just use another css toolkit/lib. just a question ... should the gatsby build handle inline svgs in a scss file? just curious |
Well, I think it's a problem because Gatsby is inlining the generated CSS into the HTML. Which is normally what you want, but in this case it's breaking the styles because of those svgs. I think it'll work correctly if it just does a |
I can confirm that if it is loaded as a synchronous link ( I wonder if |
Nah, it doesn't. Gatsby just overrides it anyway. |
ok. thanks. i'll go with the synchronous link or change the css library. thanks for your help and quick assistance. i thought it was a something i was doing wrong or a gatsby issue (which it still may be) but i've got a work around now. if you think this is not a major issue feel free to close it or keep it open (or merge it with another issue) if you think it needs to be handled by gatsby. |
I think that this is not something easily handled by Gatsby. Inlining the CSS into the HTML is an important optimization, so turning it off isn't a good idea; and I don't think this issue is common enough to justify executing some string matching on all css just to check for extra HTML elements, like That's just my opinion, though; I'll leave it up to the ones in power. 🙂 Maybe it'd make sense to add some kind of warning if this kind of scenario is detected. 🤷♂ A couple solutions/workarounds:
// gatsby-ssr.js
import React from 'react';
import vital from '!file-loader!extract-loader!css-loader!sass-loader!vital-css/sass/vital.sass';
export const onPreRenderHTML = ({ getHeadComponents, replaceHeadComponents }) => {
const components = getHeadComponents();
replaceHeadComponents(components.concat([
<link rel="stylesheet" href={vital} />
]));
}
|
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. Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Thanks again for being part of the Gatsby community! 💪💜 |
Description
difference between the develop and build static sites. both commands are working. the styling is quite different. the develop site works as expected. the build site has the the css inline in the head tag but outside of any other tag. just appears as rendered text in the browser.
Steps to reproduce
gatsby develop
view site
gatsby build
view site
both commands execute successfully
Expected result
sites should be virtually identical between develop and build
Actual result
the styling is quite different. the develop site works as expected. the build site has the the css inline in the head tag but outside of any other tag. just appears as rendered text in the browser.
Environment
Run
gatsby info --clipboard
in your project directory and paste the output here.gatsby.config.js
additional info:
The text was updated successfully, but these errors were encountered: