javascript - ng build -prod 与 ng build --prod --bu

我的 Angular 项目是 @Angular4.3.3

ng build -prod

构建需要 77 秒

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

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

控制台图像上的 block 差异:

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

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

最佳答案

--build-optimizer and --vendor-chunk

来自 Angular CLI Docs :

When using Build Optimizer the vendor chunk will be disabled by default. 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 chunk as 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/

相关文章:

ant - 没有 -q 标志让 Ant 安静?

java - ClassCastException : ApiVersionImpl cannot

angular - 找不到模块 "tslib"

android - ADT Eclipse + Gradle : incomplete BuildC

jenkins - 如何从 Jenkins 2.0 管道脚本中读取属性文件

c++ - 构建或编译

maven - 处理本地存储库中旧快照的最佳方法?

eclipse - 防止 eclipse 在运行 Ant 任务之前构建项目

delphi - 项目构建配置的上下文菜单中的 "Make"和 "Build"有什么区别?

ios - Jenkins - xcodebuild 连接对等方拒绝拒绝 dtxproxy :XCT