Skip to content
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

SSR example is not working on production build #12077

Closed
2 tasks done
frenkelor opened this issue Jul 7, 2018 · 7 comments
Closed
2 tasks done

SSR example is not working on production build #12077

frenkelor opened this issue Jul 7, 2018 · 7 comments
Labels
docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@frenkelor
Copy link
Contributor

SSR example is not working while running NODE_ENV=production npm start

I'm having the same issue on my production build

Warning: Prop className did not match. Server: "jss15 jss19 jss32" Client: "MuiTypography-root-15 MuiTypography-display1-19 MuiTypography-gutterBottom-32"

  • This is a v1.x issue (v0.x is no longer maintained).
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Server and client will render without braking the ui

Current Behavior

client-side rendering brakes the ui

Steps to Reproduce (for bugs)

  1. Clone the source code
  2. Move to the examples SSR folder
  3. run npm install
  4. run NODE_ENV=production npm start
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 7, 2018

Check out https://github.com/mui-org/material-ui/tree/master/examples/ssr. This is the reference implementation of the Server Rendering tutorial.

@oliviertassinari oliviertassinari added the status: waiting for author Issue with insufficient information label Jul 7, 2018
@frenkelor
Copy link
Contributor Author

This is the issue this example is not working @oliviertassinari

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 7, 2018

@frenkelor The demo doesn't mean to demonstrate how to configure the production env, but sure, why not. Do you want to submit a pull request with the following change?

/examples/ssr/webpack.config.js

const path = require('path');

module.exports = {
  entry: './client.js',
  output: {
    path: path.resolve(__dirname, 'build'),
    filename: 'bundle.js',
    publicPath: '/',
  },
+ mode: process.env.NODE_ENV || 'development',
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
      },
    ],
  },
};

Thanks

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process. and removed status: waiting for author Issue with insufficient information labels Jul 7, 2018
@bobbyhadz
Copy link

the above change did not solve this issue for me, once the client side takes over material ui does not initialize. An example: https://www.borislav.win/

@frenkelor
Copy link
Contributor Author

yes you are right @opmftw you need to change the npm start command too:
"start": "webpack -w --mode=production & nodemon --exec yarn babel-node -- server.js"

@frenkelor
Copy link
Contributor Author

#12080 @oliviertassinari

@oliviertassinari
Copy link
Member

@frenkelor Perfect 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

No branches or pull requests

3 participants