简体   繁体   English

生成大小10.6 MB

[英]Build size 10.6 MB

I am using Create-react-app for my application. 我正在为我的应用程序使用Create-react-app。 When I run npm run build, my build size is 10.6 MB. 当我运行npm run build时,我的构建大小为10.6 MB。 When I used source-map-explorer to analyze i got know my node modules are taking 6.3 MB and my components takes 2.84 MB, 780 KB for static and other for containers and reducers. 当我使用source-map-explorer进行分析时,我知道我的节点模块占用了6.3 MB,而我的组件占用了2.84 MB,静态占用了780 KB,而容器和缩减器则占用了其他。

Kindly help me to reduce my build size. 请帮助我减小构建尺寸。 Thanks in advance 提前致谢

It's painful! 这是痛苦的!

You have multiple packages antd , material-ui , cpexcel , froala-editor ...etc These packages are awesome, but the problem is they are very large ones. 您有多个软件包antdmaterial-uicpexcelfroala-editor ... etc这些软件包非常棒,但问题是它们很大。

You can have these notes to be considered for reducing the bundle size: 您可以考虑以下注意事项以减小捆绑包的大小:

  1. Code-Splitting and Lazy loading. 代码拆分和延迟加载。 .
  2. Don't import any static failes inside your app, it will be dealt with as a dependency and be included at your bundle, instead, use CDNs for your static files. 不要在您的应用程序内导入任何静态失败,它将作为依赖项处理并包含在您的捆绑包中,而是对您的静态文件使用CDN。
  3. Remove any un-used packages out of your package.json CLEAN IT UP. package.json清除所有未使用的软件包CLEAN IT UP。
  4. Remove any un-used import statements in your application. 删除应用程序中所有未使用的import语句。

These can bring major changes to your bundle size, depending on how much you put effort on them. 这些可能会极大地改变您的商品包大小,具体取决于您对商品的投入程度。

The other way might be ejecting the app, and customly set Webpack Configurations yourself to deal with the specifications of your project. 另一种方法可能是弹出应用程序,并自行设置Webpack配置以处理项目的规范。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM