如果我使用延迟加载模块,我的角度应用程序 main.bundle.js 文件大小会在构建时减少 [英] if im using lazy loading module my angular application main.bundle.js file size is decreased while build

查看:24
本文介绍了如果我使用延迟加载模块,我的角度应用程序 main.bundle.js 文件大小会在构建时减少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在使用

ng build --aot false --prod

ng build --aot false --prod

如果我使用延迟加载模块,我的 Angular 应用程序 main.bundle.js 文件大小会在构建时减小.

if im using lazy loading module my angular application main.bundle.js file size is decreased while build.

推荐答案

ng build 本身没有任何优化.如果你 ng build --help 你可以看到所有你可以传递的标志来进一步优化你的代码并减少输出大小.

ng build by itself does not have any optimizations. If you ng build --help you can see all the flags you can pass to further optimize your code and reduce the output sizes.

试试 ng build -prod -aot -vc -cc -dop --buildOptimizer 看看你的数字是多少.这将启用生产模式,使用 AOT,使用第三方库的供应商块,将所有公共代码提取到公共块中,确保输出路径干净,最后使用@angular-devkit/build-optimizer 进行进一步优化.

Try ng build -prod -aot -vc -cc -dop --buildOptimizer and see what your numbers are. This will enable production mode, use AOT, use a vendor chunk for third party libs, pull all common code out into a common chunk, make sure the output path is clean and lastly use the @angular-devkit/build-optimizer for further optimizations.

如果它仍然很大,那么请在您的应用程序中运行您正在使用的第三方库.(1) 你是在导入整个 RxJS 库吗?(2) 所有本地化的时刻?等等.

If that is still large, then do a run through in your application for third-party libraries that you are using. (1) Are you importing the entire RxJS library? (2) Moment with all localizations? etc..

这篇关于如果我使用延迟加载模块,我的角度应用程序 main.bundle.js 文件大小会在构建时减少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆