-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
with-ant-design bundle file is too big #4101
Comments
Try analyzing using https://github.com/zeit/next-plugins/tree/master/packages/next-bundle-analyzer |
I think it imports the whole css rather than importing just the css for the components that are used |
CSS Bundle
I believed the same, and it actually imports only what it needs in terms of CSS! 😄 I would guess the JS Bundle
The These components are super-fully-featured and rely on other packages, like components from https://github.com/react-component/ or depend on Try just importing the Conclusion
|
[ |
@aimeefe can u teach me how config babel-plugin-import with antd.now i got an error SyntaxError: Invalid or unexpected token |
@Shangyunliang ## 1. ANT Design imports optimisation ( to reduce build size )
with that build changed from 1.4MB to 560KB ## 2. ANT Design CSS import
Hope it helps |
@ashinga48 babel-plugin-import from ant-design does those things automatically. |
@ashinga48 didn't work at all |
Note there is some information in this thread about getting modular ant design. |
Webpack in CRA builds add to +219kb to initial chunk. Whereas importing manual way adds +12 i.e. becomes +231kb |
I've created export { default as SwapOutline } from '@ant-design/icons/lib/outline/SwapOutline';
export { default as UploadOutline } from '@ant-design/icons/lib/outline/UploadOutline'; And I've set the absolute imports in const path = require('path')
module.exports = {
webpack: function(config, options) {
config.resolve.alias['@ant-design/icons/lib/dist$'] = path.join(__dirname, 'src/client/icons.js')
return config
},
} Works for me, and I don't see the icons/dist in bundle analyzer. The bundle size is now reduced by 500k |
Hello, From antd 3.5 version. when I try to install npm. I am observing "@antdesign" package in nodemodules. When I try to build (npm build which uses webpack) for production and analyze the build, I am getting 2MB for that @antdesign package. Is there anyone facing the same issue? Note: I have used Babel-Import-Plugin and added the following thing as a configuration in webpack:
I tried different syntaxes using Babel-Import-Plugin (BTW, latest version) but couldn't able to reduce the production build. Please help me in figuring it out. |
I am not even using any @antddesign icons. I am just using few antd components which are also showing as separate in bundle analyzer. Please find the screenshot |
(Or) |
me too.I have the same problem. ask for help. |
See: ant-design/ant-design#12011 |
I managed to reduce the bundle size by adding 2 lines to my next.config.js:
|
This comment has been minimized.
This comment has been minimized.
@janlukasschroeder that looks like a config for cra which is different from Next.js. |
@mmiszy How do you know which icons you need to import if you're using, e.g the pagination component from |
If you want to remove unused momentjs locales: const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
module.exports = {
webpack: function(config, options) {
config.plugins.push(new MomentLocalesPlugin())
return config
},
} Check out: https://www.npmjs.com/package/moment-locales-webpack-plugin |
Change according to issue in next.js, no side effect yet. vercel/next.js#4101 (comment)
Duplicate of #9830 |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
In the with-ant-design example, i think these file too big for production. Is this a bug?
Can we optimize it?
The text was updated successfully, but these errors were encountered: