我使用Angular CLI 1.7版本中引入的budgets
选项。我使用ng build -prod --named-chunks
一切正常,可以为默认包(main
,polyfills
等)设置预算。但我找不到为自己的懒加载模块设置预算的方法。
"budgets": [
{ "type": "bundle", "name": "common", "baseline": "50kb", "warning": "25kb" },
{ "type": "bundle", "name": "inline", "baseline": "50kb", "warning": "25kb" },
{ "type": "bundle", "name": "polyfills", "baseline": "50kb", "warning": "25kb" },
{ "type": "bundle", "name": "styles", "baseline": "50kb", "warning": "25kb" },
{ "type": "bundle", "name": "main", "baseline": "500kb", "warning": "200kb" },
// this doesn't work
{ "type": "bundle", "name": "summary.module", "baseline": "200kb", "warning": "100kb" },
// this doesn't work
{ "type": "bundle", "name": "summary", "baseline": "200kb", "warning": "100kb" }
]
我没有使用type: "anyScript"
或type: "any"
,因为主捆绑包几乎总是比任何延迟加载的模块大,我必须将目标路径设置为大,不要触发main
捆绑包的警告。
答案 0 :(得分:1)
对于命名块,您必须使用<module_name>-src-lib-<module_name>-module-ngfactory
之类的语法(基于角度6)。