本文介绍了预算中的警告,初始超出最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 --prod 构建我的 Angular 7 项目时,我在 budgets 中收到警告.

我有一个 Angular 7 项目.我正在尝试构建它,但我不断收到以下警告:

预算中的警告,初始超出的最大值.预算 2 MB 超出了 1.77 MB

这些是块的详细信息:

chunk {scripts} scripts.2cc9101aa9ed72da1ec4.js (scripts) 154 kB [rendered]块{0} runtime.ec2944dd8b20ec099bf3.js(运行时)1.41 kB [entry] [rendered]块{1} main.13d1eb792af7c2f359ed.js (main) 3.34 MB [initial] [rendered]块 {2} polyfills.11b1e0c77d01e41acbba.js (polyfills) 58.2 kB [initial] [rendered]块{3}styles.33b11ad61bf10bb992bb.css(样式)379 kB [initial] [rendered]

预算到底是什么?我应该如何管理它们?

解决方案

打开 angular.json 文件并找到 budgets 关键字.

它应该看起来像:

预算":[{类型":初始",最大警告":2mb",最大误差":5mb"}]

正如您可能已经猜到的那样,您可以增加 maximumWarning 值以防止出现此警告,即:

预算":[{类型":初始",最大警告":4mb",

预算是什么意思?

性能预算是对某些值的一组限制影响场地性能,在设计和开发任何网络项目.

在我们的案例中,预算是捆绑包大小的限制.

另见:

When building my Angular 7 project with --prod, I receive a warning in budgets.

I have an Angular 7 project. I am trying to build it, but I keep getting the following warning:

WARNING in budgets, maximum exceeded for initial. Budget 2 MB was exceeded by 1.77 MB

These are the chunk details:

chunk {scripts} scripts.2cc9101aa9ed72da1ec4.js (scripts) 154 kB  [rendered]
chunk {0} runtime.ec2944dd8b20ec099bf3.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.13d1eb792af7c2f359ed.js (main) 3.34 MB [initial] [rendered]
chunk {2} polyfills.11b1e0c77d01e41acbba.js (polyfills) 58.2 kB [initial] [rendered]
chunk {3} styles.33b11ad61bf10bb992bb.css (styles) 379 kB [initial] [rendered]

What exactly are budgets? How should I manage them?

解决方案

Open angular.json file and find budgets keyword.

It should look like:

    "budgets": [
       {
          "type": "initial",
          "maximumWarning": "2mb",
          "maximumError": "5mb"
       }
    ]

As you’ve probably guessed you can increase the maximumWarning value to prevent this warning, i.e.:

    "budgets": [
       {
          "type": "initial",
          "maximumWarning": "4mb", <===
          "maximumError": "5mb"
       }
    ]

What does budgets mean?

In our case budget is the limit for bundle sizes.

See also:

这篇关于预算中的警告,初始超出最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 14:38