使用 --prod 构建我的 Angular 7 项目时,我在 budgets
中收到警告。
我有一个 Angular 7 项目。我正在尝试构建它,但我不断收到以下警告:
WARNING in budgets, maximum exceeded for initial. Budget 2 MB was exceeded by 1.77 MB
这些是 block 的详细信息:
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]
究竟什么是预算?我应该如何管理它们?
最佳答案
打开angular.json文件,找到budgets
关键字。
应该是这样的:
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
}
]
您可能已经猜到,您可以增加 maximumWarning
值来防止出现此警告,即:
"budgets": [
{
"type": "initial",
"maximumWarning": "4mb", <===
"maximumError": "5mb"
}
]
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.
在我们的案例中,预算是 bundle 大小的限制。
另见:
https://stackoverflow.com/questions/53995948/
相关文章:
android - IntelliJ 新的 android gradle 插件 (0.14.+)
java - 如何为新的 java 项目生成 build.xml?
ios - 如何使用 Ionic Framework 生成 iOS IPA 文件?
android - 防止 Android Studio/Intellij Idea 在启动时构建项目
python - 如何从源代码中使用 package_data 中的数据?
android - Gradle 无法解析项目 :linkedin-sdk
build - 如何读取 Gradle 的 registry.bin?