0

I migrated my Angular project from 8 to 9

When i execute the command ng build --prod

I'am getting multiple errors on scss files similar to the following :

ERROR in Exceeded maximum budget for /Users/HASSEN/IdeaProjects/my-anuglar-project/src/app/navigation/sidenav-content/sidenav-content.component.scss. Budget 10 kB was not met by 51.9 kB with a total of 61.9 kB.

I don't want to increase the budget limit in the angular.json file because it's unreasonable since i didn't modify any of those scss files.

      "buildOptimizer": true,
      "budgets": [
        {
          "type": "initial",
          "maximumWarning": "5mb",
          "maximumError": "6mb"
        },
        {
          "type": "anyComponentStyle",
          "maximumWarning": "6kb",
          "maximumError": "10kb"
        }
      ]
  • did your css grow, or did the limit got lower ? Could you show your `sidenav-content.component.scss` ? Does it have any import ? – Random Jul 04 '23 at 09:43
  • @Random yes, it has an import of theme.css file which has the following import `@import '~@angular/material/theming';` I guess then that the @angular/material/theming has grown, what to do in this situation ? – Hassen Gaaya Jul 04 '23 at 09:50
  • indeed, you should NOT include a theme in a component scss. Why do you import this file ? things like `mat-color($app-theme, primary)` ? – Random Jul 04 '23 at 09:51
  • what is your angular-material version ? – Random Jul 04 '23 at 09:57
  • the purpose of `@import '~@angular/material/theming';` is to include `@include mat-core();` The material version is 9.2.4 – Hassen Gaaya Jul 04 '23 at 10:00
  • the theme should not be included in a component SCSS. It should be imported in your styles.scss (or a distinct file, which is imported by your styles.scss) – Random Jul 04 '23 at 10:01
  • So now i'am getting **Undefinded Variable** on $myvariable-primary defined in theme.scss and used in a component scss file => background-color: mat-color($myvariable-primary); – Hassen Gaaya Jul 04 '23 at 12:48
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/254364/discussion-between-hassen-gaaya-and-random). – Hassen Gaaya Jul 04 '23 at 12:49

0 Answers0