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

speed up build by fixing mui imports #189

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions next.config.js
@@ -1,4 +1,6 @@

const PluginTransformImport = require('swc-plugin-transform-import').default;

const config = {
poweredByHeader: false,
webpack5: true,
Expand All @@ -16,6 +18,24 @@ const config = {
test: /\.svg$/,
use: ['@svgr/webpack']
});
const swcRule = _config.module.rules.find(rule => rule.use?.loader === 'next-swc-loader');
swcRule.use.options.plugin = (m) => new PluginTransformImport({
'@mui/material': {
// eslint-disable-next-line no-template-curly-in-string
transform: '@mui/material/${member}',
preventFullImport: true
},
'@mui/icons-material': {
// eslint-disable-next-line no-template-curly-in-string
transform: '@mui/icons-material/${member}',
preventFullImport: true
},
'@mui/lab': {
// eslint-disable-next-line no-template-curly-in-string
transform: '@mui/lab/${member}',
preventFullImport: true
}
}).visitProgram(m);
return _config;
}
};
Expand Down