ERROR in Exceeded maximum budget for E:/project/

Viewed 13245

good morning, I have created my project and now I want to output with the ng build --prad command, but I have encountered an error. How can I fix this error? I guess the problem is from the following code, but I do not know how to fix it

    "budgets": [
         {
         "type": "initial",
         "maximumWarning": "2mb",
         "maximumError": "5mb"
         },
         {
         "type": "anyComponentStyle",
         "maximumWarning": "6kb",
         "maximumError": "10kb"
         }
    ]

error in terminal:

ng build --prod

    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/layout-dialog/dialog-successful/dialog-successful.component.scss. Budget 6 kB was not met by 17.4 kB with a total of 23.4 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/login/login.component.scss. Budget 6 kB was not met by 201 kB with a total
    of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/about-me/about-me.component.scss. Budget 6 kB was not met by 201 kB with a total of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/header-admin/header-admin.component.scss. Budget 6 kB was not met by
    201 kB with a total of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/show-documents/show-documents.component.scss. Budget 6 kB was not met
    by 201 kB with a total of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/show-expertise/show-expertise.component.scss. Budget 6 kB was not met
    by 204 kB with a total of 210 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/show-records/show-records.component.scss. Budget 6 kB was not met by 200 kB with a total of 206 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/contact-me/contact-me.component.scss. Budget 6 kB was not met by 202 kB with a total of 208 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/about-me-admin/about-me-admin.component.scss. Budget 6 kB was
    not met by 201 kB with a total of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/documents-admin/documents-admin.component.scss. Budget 6 kB was not met by 201 kB with a total of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/expertise-admin/expertise-admin.component.scss. Budget 6 kB was not met by 204 kB with a total of 210 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/messages-admin/messages-admin.component.scss. Budget 6 kB was
    not met by 200 kB with a total of 206 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/records-admin/records-admin.component.scss. Budget 6 kB was not met by 201 kB with a total of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/home.component.scss. Budget 6 kB was not met by 225 kB with a total of 231 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/records-admin/ae-record/ae-record.component.scss. Budget 6 kB
    was not met by 201 kB with a total of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/documents-admin/ae-documents/ae-documents.component.scss. Budget 6 kB was not met by 200 kB with a total of 206 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/about-me-admin/edit-about-me-admin/edit-about-me-admin.component.scss. Budget 6 kB was not met by 201 kB with a total of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/expertise-admin/ae-expertise/ae-expertise.component.scss. Budget 6 kB was not met by 201 kB with a total of 207 kB.
    
    WARNING in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/layout-dialog/dialog-delete/dialog-delete.component.scss. Budget 6 kB was not met by 224 kB with a total of 230 kB.
    
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/layout-dialog/dialog-successful/dialog-successful.component.scss. Budget 10 kB was not met by 13.4 kB with a total of 23.4 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/login/login.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/about-me/about-me.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/header-admin/header-admin.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/show-documents/show-documents.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/show-expertise/show-expertise.component.scss. Budget 10 kB was not met by 200 kB with a total of 210 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/show-records/show-records.component.scss. Budget 10 kB was not met by 196 kB with a total of 206 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/contact-me/contact-me.component.scss. Budget 10 kB was not met by 198 kB with a total of 208 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/about-me-admin/about-me-admin.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/documents-admin/documents-admin.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/expertise-admin/expertise-admin.component.scss. Budget 10 kB was not met by 200 kB with a total of 210 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/messages-admin/messages-admin.component.scss. Budget 10 kB was not met by 196 kB with a total of 206 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/records-admin/records-admin.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/home/home.component.scss. Budget 10 kB was not met by 221 kB with a total of
    231 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/records-admin/ae-record/ae-record.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/documents-admin/ae-documents/ae-documents.component.scss. Budget 10 kB was not met by 196 kB with a total of 206 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/about-me-admin/edit-about-me-admin/edit-about-me-admin.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/expertise-admin/ae-expertise/ae-expertise.component.scss. Budget 10 kB was not met by 197 kB with a total of 207 kB.
    ERROR in Exceeded maximum budget for E:/project/PwpEnd/PWP/src/app/layout/admin/layout/layout-dialog/dialog-delete/dialog-delete.component.scss. Budget 10 kB was not met by 220 kB with a total of 230 kB.

angular.json:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "PWP": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/PWP",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": true,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss",
              "./node_modules/bootstrap/dist/css/bootstrap.css"
            ],
            "scripts": [
              "./node_modules/bootstrap/dist/js/bootstrap.js",
              "./node_modules/bootstrap/dist/js/bootstrap.js"
            ]
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "PWP:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "PWP:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "PWP:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        },
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "PWP:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "PWP:serve:production"
            }
          }
        }
      }
    }
  },
  "defaultProject": "PWP",
  "cli": {
    "analytics": "c792c032-9136-42b5-8b0a-391b6f8d84c5"
  }
}

pakege.json:

{
  "name": "pwp",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~9.1.7",
    "@angular/cdk": "^9.2.4",
    "@angular/common": "~9.1.7",
    "@angular/compiler": "~9.1.7",
    "@angular/core": "~9.1.7",
    "@angular/forms": "~9.1.7",
    "@angular/material": "^9.2.4",
    "@angular/platform-browser": "~9.1.7",
    "@angular/platform-browser-dynamic": "~9.1.7",
    "@angular/router": "~9.1.7",
    "bootstrap": "^4.6.0",
    "jquery": "^3.5.1",
    "jspdf": "^2.3.0",
    "ngx-cookie-service": "^11.0.2",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.6",
    "@angular/cli": "~9.1.6",
    "@angular/compiler-cli": "~9.1.7",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/jspdf": "^1.3.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~5.0.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  }
}

app.routing.module.ts:

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { ValidTokenRoutingGuard } from './valid-token-routing/valid-token-routing-guard';
const routes: Routes = [
  { path: '', loadChildren: () => import('./layout/home/home.module').then(m => m.HomeModule) },
  { path: 'Admin', canActivate: [ValidTokenRoutingGuard], loadChildren: () => import('./layout/admin/admin.module').then(m => m.AdminModule) },
  { path: 'Login', loadChildren: () => import('./layout/login/login.module').then(m => m.LoginModule) },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }

app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { HttpClientModule } from '@angular/common/http';
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    BrowserAnimationsModule,
    HttpClientModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
1 Answers

It is a compiler error so you notice that your files are below the defined size. Just modify the configuration in angular.json and increase the maximumError size properties to suit your needs and build again. I would also recommend to check your project in order to remove any unused code or dependencies so that the size is reduced .

Related