本文介绍了ng build -prod vs ng build --prod --build-optimizer = true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

My Angular项目是@ Angular4.3.3

My Angular project is @Angular4.3.3

花费77秒进行构建

制作构建需要190秒,没有供应商块,尺寸较小(但是尺寸差别不大)

Takes 190 seconds to make a build, No vendor chunk, less in size(but not big difference in size though)

控制台图像上的块差异:

Chunk differences on console image:

我阅读了但仍然没有得到这些命令创建的构建之间的明显区别。

I read Bundling & Tree-Shaking but still don't get the clear difference between builds created by those commands.

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

推荐答案

--build-optimizer and --vendor-chunk

使用Build Optimizer时,默认情况下将禁用供应商块。您可以使用--vendor-chunk = true覆盖它。

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

如果没有单独的供应商组块,使用Build Optimizer的总包大小会更小,因为与应用程序代码在同一块中的供应商代码使得Uglify可以删除更多未使用的代码。

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

参见:

这篇关于ng build -prod vs ng build --prod --build-optimizer = true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 18:09