-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Add documentation for MUI5 with ts, npm, styled-components, webpack #28657
Comments
@dash-tobin thanks for sharing this. We try to keep https://github.com/mui-org/material-ui/tree/HEAD/examples/create-react-app-with-styled-components up to date regarding the integration with styled-components. As you already mentioned, you need to add: webpack alias - https://github.com/mui-org/material-ui/blob/master/examples/create-react-app-with-styled-components-typescript/config-overrides.js#L5 It would have been much more easier if npm supported package aliases, but for now, this is the recommended setup.
You should use the Regarding the styled components integration, we have a note in this step about how to install it: https://mui.com/guides/migration-v4/#update-mui-version The guide is already pretty long, it would be much more confusing if we were to include in it setup for styled-components too. I am open to ideas about how we can improve it. |
Thank you for the response. I did look at this documentation before creating the issue, so it may be just me in this boat, but my hope is that others could also be helped by even more robust documentation. Though the migration doc is long I wouldn't mind more clarification if it means easier migration. Splitting these specifics here: How to Switch to Styled-Components, is a nice touch. This could be a home for emotion requirement (if using npm) I pointed to earlier.
|
This looks like a bug in the codemod. Could you maybe provide a simple reproduction of it? A file or parts of file could be enough.
Note that |
That is a great info I didn't see mentioned literally anywhere else. excluding |
If you are using import { styled } from '@mui/material/styles';
// or
import { styled } from '@mui/material'; |
Where should I import { css } from? Following gives me errors:
Gives big ts error ending in With But I think that results in 2 instances of name generator in the app, breaking class names in ssr |
Please check the documentation. https://mui.com/guides/interoperability/#the-css-prop |
This is a link to Emotion section of the page. I'm using styled-components, same as the issue op |
@mnajdova I am not sure about styled-components |
And while we're here, there is also |
We are not re-exporting the I will take a look now on the |
@MonstraG please create a new issue for the TypeScript issue regarding the CSS prop. It's likely that we would need to update the typings for the For styled-components, npm and webpack please see #28559 There is already a PR that will close the issue. I am marking this as duplicate of #28559 |
I'm having a difficult time migrating an existing project from v4 to v5 using ts, npm, styled-components, and webpack module federation.
Summary 💡
Help users who already have styled-components in an existing project migrate to MUI5
It should describe and give implementation examples of using StyledEngineProvider with both emotion and styled-components.
Official documentation describing the issues around styled-components and npm, mainly the (to date) requirement of emotion (#27846 (comment)).
*Included should describe why the codemon preset-safe imports StyledEngineProvider from styled-components and how to proceed with the migration using this implementation method (examples).
It should describe how to add styled-engine-sc aliases and plugins to webpack config & tsconfig
If anything, it should help users migrate from styled-components to emotion
FYI codemon preset-safe does not wrap styled-components ThemeProvider in StyledEngineProvider
Examples 🌈
if using typescript:
add this to paths object in tsconfig.json
"paths": { ... "@mui/styled-engine": ["./node_modules/@mui/styled-engine-sc"] }
If using webpack:
Add these lines to webpack.config.js
If npx codemon preset-safe does not wrap styled-components ThemeProvider, you must change order of components ( or correct me with needed information):
not
Motivation 🔦
I am trying to get my company to upgrade to material-ui v5
The text was updated successfully, but these errors were encountered: