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

标签 javascript angular build angular-cli

我的 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 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/

相关文章:

c# - Visual Studio 不更新构建

c# - 当我构建 Silverlight 项目时,XAML 文件会发生什么情况?

javascript - 如何从事件中获取原始元素?

angular - 'npm 错误!缺少脚本 : ngcc' error with NPM

angular - 如何检查 Angular 应用程序是在生产模式还是开发模式下运行

javascript - ionic 2 : Object 'Date' doesn't work on Ios

c++ - 如何使用 Visual Studio 2008 构建 libevent 版本 2.0.10

javascript - jQuery Mobile 在另一个函数完成后执行一个函数

javascript - Bootstrap 导航栏下拉列表隐藏在 html 选择选项后面

javascript - 将 javascript 添加到 iframe?