IMPORTING BOOTSTRAP VARIABLE in SCSS
file getting error
WARNING in Exceeded maximum budget for B:/Angular-8/crats-shop/src/app/shared/components/sort/sort.component.scss. Budget 6 kB was not met by 136 kB with a total of 142 kB
IMPORTING BOOTSTRAP VARIABLE in SCSS
file getting error
WARNING in Exceeded maximum budget for B:/Angular-8/crats-shop/src/app/shared/components/sort/sort.component.scss. Budget 6 kB was not met by 136 kB with a total of 142 kB
budget is a group of limits to certain values that affect site performance
Open angular.json file and find budgets keyword and increase value
"budgets": [
{
"type": "initial",
"maximumWarning": "4mb", <===
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "150kb",
"maximumError": "150kb"
}
]
Even though you can just bump up your limits, it's probably not what you want to do. The limits are there for a reason. You should try to avoid exceeding them in the first place if possible.
For me, the problem was I was importing my theme file (which was quite large) into my components' SCSS files.
@import "src/my-theme";
The only reason for that was that I needed to access my SCSS color variables within those files. It's a terrible idea to import any larger file in multiple of your styles only to access a few of your variables; your application will become huge and really slow to load.
If you only need access to your variables, I suggest this solution:
:root { --primary-color: #11dd11; }
var(--primary-color)
Open angular.json
file and find budgets keyword and increase value of type anyComponentStyle
:
{
"type": "anyComponentStyle",
"maximumWarning": "150kb",
"maximumError": "150kb"
}
kozenka's answer put me on the right track.
I was facing this and realized that my problem was all the Angular mixins that I was including in my theme file, which was used by other style files. My /src/theme.scss
file looked something like:
@use `@angular/material` as mat;
@include mat.core(); // <-- this brings up the size a bit although not excessively
$theme: mat.define-dark-theme(...); // <-- the palettle (map of colors) that I use throughout the app
@include mat.all-legacy-components.themes($theme); // <-- this is very heavy
I need this last one since I'm using a lot of legacy components and migrating from legacy to MDC left me with a lot more work figuring out how to fit things in the new style given that many of the scss tags I was using before did no longer apply apparently (and I can't store the $theme
variable into a CSS :root
variable because it's a map and not a simple color code).
My solution was to create a different file, mixins.scss
where I import the themes file and do all my includes (and any other necessary mixins). i.e:
/**
/src/theme.scss
*/
@use `@angular/material` as mat;
$theme: mat.define-dark-theme(...);
/**
/src/mixins.scss
*/
@use `@angular/material` as mat;
@use `/src/theme.scss` as *;
@include mat.core();
@include mat.all-legacy-components.themes($theme);
Just be sure to also include the new mixins file in /src/styles.scss
, so those mixins styles are included in the overall style.