Next.js
- Typescript Based Next Project Create
yarn create next-app app --typescript
- Add MUI
- to use default style engine
yarn add @mui/material @emotion/react @emotion/styled
- to use styled-components
yarn add @mui/material @mui/styled-engine-sc styled-components
typescript
{
"dependencies": {
- "@mui/styled-engine": "latest"
+ "@mui/styled-engine": "npm:@mui/styled-engine-sc@latest"
},
+ "resolutions": {
+ "@mui/styled-engine": "npm:@mui/styled-engine-sc@latest"
+ },
}
{
"compilerOptions": {
+ "paths": {
+ "@mui/styled-engine": ["./node_modules/@mui/styled-engine-sc"]
+ }
},
}
+const withTM = require('next-transpile-modules')([
+ '@mui/material',
+ '@mui/system',
+ '@mui/icons-material', // If @mui/icons-material is being used
+]);
+module.exports = withTM({
webpack: (config) => {
config.resolve.alias = {
...config.resolve.alias,
+ '@mui/styled-engine': '@mui/styled-engine-sc',
};
return config;
}
+});