延迟加载模块的Angular CLI预算

时间:2018-04-06 13:02:22

标签: angular angular-cli

我使用Angular CLI 1.7版本中引入的budgets选项。我使用ng build -prod --named-chunks

生成我的捆绑包

一切正常,可以为默认包(mainpolyfills等)设置预算。但我找不到为自己的懒加载模块设置预算的方法。

enter image description here

  "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捆绑包的警告。

1 个答案:

答案 0 :(得分:1)

对于命名块,您必须使用<module_name>-src-lib-<module_name>-module-ngfactory之类的语法(基于角度6)。