我的 Angular 项目是 @Angular4.3.3
ng build -prod
构建需要 77 秒
ng build --prod --build-optimizer=true
构建需要 190 秒,没有 vendor 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/