angular - Is there a way to create a separate bundle file for dependencies in package.json using angular-cli?
问题描述
I have multiple angular applications that I load in multiple pages. I am trying to minimize bundle download size when I am loading a particular application. I cannot use lazy loading here as I am using multiple angular application, but all of these applications have same dependencies.
When I try ng build --prod
, it includes the dependency code within main.js bundle, which I don't want. I want to get dependency code bundle separately so that I don't download redundant code when I am navigating through pages.
解决方案
是的,
--vendor-chunk=true
或者在配置选项下的 angular.json 中:
"vendorChunk": true,
来自 build 命令的 angular-cli 文档:
When using Build Optimizer the vendor chunk will be disabled by default. You can override this with --vendor-chunk=true.
https://github.com/angular/angular-cli/wiki/build#--build-optimizer-and---vendor-chunk
推荐阅读
- wordpress - 安装 Polylang for WooCommerce 后没有语言选项
- sql - 根据进入另一个表的列更新表
- c++ - FFmpeg h265 编码->解码,C++
- java - Java内存泄漏验证
- html - 如何更改 SVG 的高度,以便用户不必向下滚动?
- cmd - 执行带有参数的 jar 隐藏一些参数的文本
- groovy - 如何使用 groovy.util.XmlParser 访问包含句点的 XML 节点
- chilkat - 为什么 purebasic chilkat 模块 30 天试用激活语法失败?
- apache-kafka - Kafka Streams - init() 中的转发记录
- javascript - 过滤模态div内的数据