问题
webpack - v4+
material ui - v4.9.6
react - v16.12.0
In a normal way all classes should be as the last one from the first example. In some reason on production mode, many of the classes do not change. Any idea?
Example 1:
<div class="MuiDrawer-root MuiDrawer-docked jss408"></div>
Example 2:
<div class="MuiPaper-root jss469 MuiPaper-elevation1 MuiPaper-rounded"></div>
回答1:
styles className
is not designed as deterministic in prod mode.
But the generated class names of the @material-ui/core
components behave differently. When the following conditions are met, the class names are deterministic:
- Only one theme provider is used (No theme nesting)
- The style sheet has a name that starts with Mui (all Material-UI components).
- The disableGlobal option of the class name generator is false (the default).
Refer:
- Document of Material-UI className generation
- API of the generator creategenerateclassname
来源:https://stackoverflow.com/questions/60817202/material-ui-webpack-react-the-classname-optimization-minification-in-produ