我创建了一个 NX monorepo 工作区,其中“libs”文件夹中的每个库都有一个 nx.json 文件和一个 project.json。
当我尝试构建整个项目时,出现以下错误:
Warning: /<my-workspace>/libs/layout/src/lib/components/panel/panel.component.scss exceeded maximum budget. Budget 2.05 kB was not met by 1.55 kB with a total of 3.60 kB.
Warning: /<my-workspace>/libs/messenger/src/lib/components/messages-viewer/messages-viewer.component.scss exceeded maximum budget. Budget 2.05 kB was not met by 122 bytes with a total of 2.17 kB.
Warning: bundle initial exceeded maximum budget. Budget 512.00 kB was not met by 938.53 kB with a total of 1.45 MB.
Error: bundle initial exceeded maximum budget. Budget 1.05 MB was not met by 401.95 kB with a total of 1.45 MB.
由于我使用了最新版本的 NX (@nx/angular 19.4.4),我的工作区中没有任何workspace.json 或 angular.json 文件可以让我解决这个问题。
那么,像下面这样的设置应该放在哪里呢?
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
]
如果我尝试添加到每个库的project.json 文件,我会收到以下错误:
在架构中找不到 NX“预算”
那么,如何修复这个错误呢?
您可以在您的project.json文件中找到它
项目.json
targets --> <build-target> --> configurations --> <enviroment-name> --> budgets