-
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
gatsby build results in different CSS to that of gatsby develop #8560
Comments
@jonathan-chin can you please provide relevant environment information by running Also, I noticed that you are using Gatsby v1 from your package.json in the repo you shared. Please use |
when I downgrade my global gatsby-cli to 1.9.X, I get the CSS issue. when I keep it at 2.0.0-rc.1, it gives me the |
@jonathan-chin I understand that you are getting the CSS issue with Thanks for sharing the reproduction repo. I'll take a look at that. |
@jonathan-chin would it possible for you to tell which CSS is exactly differing in develop vs build? |
@kakadiadarpan this is what I get from build: You can see that their CSS classes are different. I don't recall this being an issue before. The last good build (where CSS was not affected) was https://gitlab.com/sharemeals/gatsby-site/commit/4342a715d6a1cdcb2808e5450819753be6f56a19 |
I think the fix for this is #8092. @jonathan-chin would you be able to pull the contents of that fix down, and then try with those changes? Note: if you haven't seen it yet, the How to Contribute section of Gatsby's docs contains info on how to get set up with gatsby-dev-cli, which you'll need to test it out! |
Also @jonathan-chin looks like you're on Gatsby v1. Would you be able to upgrade to Gatsby v2 to get this fix? |
@DSchau sorry it took me so long to get back to this. migrating the existing project to v2 was too much work. I decided to start a new v2 starter and migrate it piece by piece (copying and modifying as needed). In this case, gatsby develop produces radically different output than gatsby build: comparing the css styles of two identical elements on build and develop: build:
develop:
I have some Material UI overriding scss that I load into the layout component in v2. in develop, it seems to merge them well but in build, it seems to be ignoring them? can that be the cause? I just have an |
@jonathan-chin did you try this with v2 or as per steps mentioned in the comment by @DSchau above? |
@kakadiadarpan Sorry, I don't have the capacity (ie time) to set up that work flow. After looking at the PR fix, it seems to be the same issue I'm experiencing. I can close this issue for now and monitor the PR. |
@kakadiadarpan sorry, I just realized something strange. When my site first loads, the CSS is wacky. but forcing it to reload the index page, the CSS loads fine. Here are the steps to reproduce:
(the emerson quote is indicative of other CSS changes. I'm only calling this one out because it is the most visible) |
@jonathan-chin Thank you for the update. I'm able to reproduce the issue with the steps that you provided. Are you using Gatsby |
Solved it by moving the heading styles to System:
OS: macOS High Sierra 10.13.5
CPU: x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.11.4 - ~/n/bin/node
Yarn: 1.2.1 - /usr/local/bin/yarn
npm: 6.4.1 - ~/n/bin/npm
Browsers:
Chrome: 69.0.3497.100
Firefox: 62.0.2
Safari: 11.1.1
npmPackages:
gatsby: ^2.0.7 => 2.0.8
gatsby-plugin-google-analytics: ^2.0.0-rc.2 => 2.0.0-rc.2
gatsby-plugin-google-fonts: ^0.0.4 => 0.0.4
gatsby-plugin-react-helmet: ^3.0.0-rc.1 => 3.0.0
gatsby-plugin-styled-components: ^3.0.0 => 3.0.0
gatsby-plugin-typography: ^2.2.0 => 2.2.0
gatsby-remark-prismjs: ^3.0.1 => 3.0.1
gatsby-source-contentful: ^2.0.1-beta.15 => 2.0.1
gatsby-transformer-remark: ^1.7.44 => 1.7.44 |
@kakadiadarpan that's using |
@jonathan-chin can you try suggestions provided by @DSchau in this comment? |
@kakadiadarpan I think I tried to implement this just now. I installed gatsby-cli-dev, forked and pulled, switched the branch, etc etc. The issue still persists. How can I double check that the new node_modules/gatsby that I have is correct and not the old one? |
I am facing the same issue. The gatsby develop and gatsby build versions are very different for me. If I land directly or refresh a page with material-ui components, the CSS is broken for those components. The classes are present in the source but they aren't applied to the elements. If I follow a I have also noticed that if I run
(I have never used gatsby-plugin-offline) You can check out the website at http://pawanhegde.netlify.com To see the "expected" version, click on any of the comically large icons near the bottom. I haven't had the time yet to try the fix for #8092 |
It did not fix the issue for me. I still see the same behaviour. ExpectedActual |
This is also happening exactly as described for me. I tried the fix in #8092 and it worked for most pages, but did not work for all of them.
|
I solved this issue by doing the following
by reversing the order I was able to specify the order in which I wanted to import css in the html.
Solution:Change order of imports |
I'm having the same issues, among many others:
These issues are such a drag that they unfortunately seem to outweigh any of the benefit of Gatsby for me, and forcing me to switch back to Create React App. |
We're closing this issue in favor of #17914 to keep things organized. |
I also got this issue. the Gatsby develop environment was fine but in build when reloading the problem page. className's and even inline style was being stripped out of the certain tags. Which left me with an div with no attributes but all the children were rendered. however when i changed route using the gatsby link router rather than full page refresh. it fixes the issue. This drove me Mad for hours. I found a horrendous fix, probably not a good practice but it did work For now. But I changed the (div) tag to (article) Suddenly the
became
on build It also worked with ul and pre. |
Thanks for the crazy workaround @stefantrinh1 - I too am experiencing this crazy css behavior If anyone wants to see it replicated, I have a public repo and have deployed both versions: seems to work with @stefantrinh1 's does not work |
I had similar issue while conditionally trying to load a component based on the cookie value. Of course, this did not work as you have SSR on production (not sure why it works in dev mode though). Anyway, what I ended up doing is wrapping my check inside |
My problem was that I was using |
Same issue in 2020. Clicking on fixes the issue but on full reload issue is present. |
i have same problem as emailnikola |
In my case, |
2021 same problem. not touching Gatsby ever again |
@eyalroth thanks! Your solution worked for my Gatsby site 💯 |
I am facing the same issue. The gatsby develop and gatsby build versions are very different for me. In one specific page of my site, all of the CSS classes are replaced with It is late and I have yet to try any of the proposed solutions, I will update my comment once I have tested them. |
Try enabling DEV_SSR as it eliminates many of the differences between development and production #28138 |
If I do that, I get
during compilation. |
Ok you probably need to update your gatsby version then. |
2022 and the issue persists. Clearly Gatsby is not suitable for use. It'd be good to get an official resource on alternatives, and perhaps updating the main Gatsby site dissuading people from bothering to learn it. |
I have the same issue. When running gatsby develop, everything looks great. but after gatsby build, some of the assets are showing up differently. |
If anyone is still running into this issue in 2024, I recently encountered it and I was able to resolve it by removing the |
I just noticed this happen with my latest push. Up til then, it worked fine.
I have a Netlify account connected to GitLab and it builds and deploys from there.
I followed the suggested actions in #5734 but it didn't work for me. I don't think I use the offline plugin mentioned there either.
Notably, I recently had an issue with BrowserslistError: Unknown browser query
dead
. Downgrading my global gatsby package from 2.X to 1.9.X fixed that but might have caused this CSS issue as a result?... How can I solve either of these problems?
The repo is public here: https://gitlab.com/sharemeals/gatsby-site
update it seems I have the gatsby-plugin-offline package in my package.json. However, removing it from there and from node_modules doesn't seem to make a difference. I might have installed it without actually implementing it.
The text was updated successfully, but these errors were encountered: