gpt4 book ai didi

javascript - ng build -prod 与 ng build --prod --build-optimizer=true

转载 作者:IT老高 更新时间:2023-10-28 11:20:33 41 4
gpt4 key购买 nike

我的 Angular 项目是 @Angular4.3.3

ng build -prod

构建需要 77 秒

ng build --prod --build-optimizer=true

构建需要 190 秒,没有 vendor block ,大小更小(但大小差异不大)

控制台图像上的 block 差异: Difference between those two builds

我读过 Bundling & Tree-Shaking但仍然没有得到这些命令创建的构建之间的明显区别。

为什么会有这两种不同的方式,性能或其他方式有什么区别?

最佳答案

--build-optimizer and --vendor-chunk

来自 Angular CLI Docs :

When using Build Optimizer the vendor chunk will be disabled bydefault. You can override this with --vendor-chunk=true.

Total bundle sizes with Build Optimizer are smaller if there is no separate vendor chunk because having vendor code in the same chunkas app code makes it possible for Uglify to remove more unused code.

关于javascript - ng build -prod 与 ng build --prod --build-optimizer=true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48592332/

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com