问题描述
使用 --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",
预算是什么意思?
性能预算是对某些值的一组限制影响场地性能,在设计和开发任何网络项目.
在我们的案例中,预算是捆绑包大小的限制.
另见:
- https://github.com/webpack/webpack/issues/3216
- https://angular.io/guide/build#configure-size-budgets
- 性能预算(保持低请求数和小文件大小)
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:
- 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)
这篇关于预算中的警告,初始超出最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!