预算警告,初始预算超出上限 [英] WARNING in budgets, maximum exceeded for initial

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

问题描述

当使用--prod构建我的angular 7项目时,我在预算中发出警告.

When build my angular 7 project with --prod, i have a warning in budgets.

我有一个angular 7项目,我想构建它,但是我有一个警告:

I have a angular 7 project, i want to build it, but i have a warning:

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

这些是块的详细信息:

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? and how should i manage them?

推荐答案

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

Open angular.json file and find budgets keyword.

它应该像这样:

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

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

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?

效果预算是对某些值的一组限制,这些限制可以 影响网站的性能,这在设计中可能不会超过 开发任何Web项目.

A performance budget is a group of limits to certain values that affect site performance, that may not be exceeded in the design and development of any web project.

在我们的情况下,预算是捆绑商品大小的限制.

In our case budget is the limit for bundle sizes.

另请参阅:

  • https://github.com/webpack/webpack/issues/3216
  • https://angular.io/guide/build#configure-size-budgets
  • Performance Budgets (Keep Request Counts Low And File Sizes Small)

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆