当我构建 Angular 12 项目时,出现以下错误:
错误:初始超出最大预算。预算 5.00 MB 未达到 197.06 kB,总计 5.19 MB
我的 angular.json:
"budgets": [
{
"type": "initial",
"maximumWarning": "4mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kb",
"maximumError": "4kb"
}
],
Run Code Online (Sandbox Code Playgroud)
但我仍然有错误。
我该如何解决这个问题?
感谢。
我想压缩构建angular项目时创建的包文件.我ng build --environment=${environment}用来构建当前的应用程序和版本"@angular/compiler-cli": "^4.0.0"不生成.gz文件到dist文件夹.生成.gz包文件的最简单方法是什么(最好不要触摸webpack.config.js文件)?PS:我知道.gz有时创建文件的选项会被angular/cli团队删除.但我绝望地需要它,因为我的捆绑文件非常庞大.
运行时出现以下错误npm build --prod:
Error: budgets: initial exceeded maximum budget. Budget 1.00 MB was not met by 500.42 kB with a total of 1.49 MB.
我也收到此警告:
Warning: C:\Users\PATH_TO_FILE\socket.service.ts depends on 'socket.io-client'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies
我还导入了很多 Angular Material 模块。这是我的app.module.ts(这是我整个项目中唯一的模块):
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { FontAwesomeModule } from …Run Code Online (Sandbox Code Playgroud) 如何ng build project在不编辑 angular.json 的情况下修复in angular
这是错误
Your global Angular CLI version (8.3.16) is greater than your local
version (8.1.3). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
chunk {0} runtime-es2015.52e4031f7f0d4c5547f5.js (runtime) 2.25 kB [entry] [rendered]
chunk {1} main-es2015.4e8665ff7ceef4e442ee.js (main) 4.62 MB [initial] [rendered]
chunk {2} polyfills-es2015.556027bb8b3cb9b5932e.js (polyfills) 173 kB [initial] [rendered]
chunk {3} styles.26e824d23ac01d2a1ba0.css (styles) 695 kB [initial] [rendered]
chunk {4} 4-es2015.823687dfc617d3f0d9c2.js () 3.43 kB [rendered]
chunk {5} …Run Code Online (Sandbox Code Playgroud) angular ×3
angular-cli ×2
angular7 ×1
angular8 ×1
compression ×1
gzip ×1
javascript ×1
node.js ×1
optimization ×1
socket.io ×1
typescript ×1