dev run shows different styling than production build
See original GitHub issueAre you reporting a bug?
I am trying to build static site using material-ui. Sample is at: https://github.com/paramr/react-static-issue/tree/master . when I run in dev i see styling of UI which disappears when I run in prod.
Dev:
Prod:
Environment
react-static -V
: 6.0.11node -v
: v10.14.2npm -v
: 6.4.1- Operating system: mac OS - 10.14.2
- Browser and version (if relevant): Repros on safari and chrome
Steps to Reproduce the problem
I started from archives/old-examples/material-ui and fixed issues that arose to get it working for dev. Repro steps are:
- $ git clone https://github.com/paramr/react-static-issue.git
- $ cd react-static-issue
- $ npm install
- $ npm run start
- open http://localhost:3000 on browser.
- $ non run build-dbg
- $ cd dist
- $ python3 -m http.server 8080
- open http://localhost:8080 on browser
Expected Behavior
Both sites should look the same.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
React: Production build looks different from development build
I had an issue where in production, the setState getting called twice, and somehow it run in parallel. The result rendered was half...
Read more >CSS Properties of production build are different than local build.
Notice that the source of the styles is different between your local and production builds; when running locally, your styles are injected ...
Read more >Organizing your CSS - Learn web development | MDN
Does your project have a coding style guide? · Keep it consistent · Formatting readable CSS · Comment your CSS · Create logical...
Read more >Optimizing Performance - React
If you visit a site with React in development mode, the icon will have a red ... Then, to create a production build,...
Read more >Creating a Production Build - Create React App
npm run build creates a build directory with a production build of your app. Inside the build/static directory will be your JavaScript and ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The process of static generation doesn’t happen at dev time, as this would be too costly and slow and just doesn’t make sense for developer experience.
Both
renderToElement
andrenderToHtml
are methods that are used only to produce the static HTML for the static site. That HTML is then used as the starting point for the app to rehydrate.Just as with any static site generation in React, there are side effects of rendering that must be extracted and pushed into the resulting HTML so as to ensure that the HTML markup looks exactly the same as the post-mounted react markup.
These methods provide a place to do that (but I can see how they are a bit confusing), and to be honest, most of this should be happening in plugins that we haven’t built yet.
You can still achieve what you are wanting without a plugin for now though.
This repo has a working static export configuration for matierial UI: https://github.com/cbroberg/react-static-mui
In fact, let’s track this issue there (#896) from here on out.
Thanks for explanation.