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
The budgets will be automatically enforced on each build with the Angular CLI. Consider introducing budget monitoring as part of continuous integration (which can also be achieved with the Angular CLI).
Budget 6 kB was not met by 202 kB with a total of 208 kB. Most of this budget overflow is from importing ~@angular/material/theming. Is it ok to increase budgets in angular.json to ~2-500kB, what are the drawbacks of doing this?
There's a budget for a JavaScript bundle called main. If the main bundle gets bigger than 170 KB, the Angular CLI will show a warning in the console when you build the app. If the main bundle gets bigger than 250 KB, the build will fail.
First thing to make sure is that we have @angular/cli: "1.7.0" installed in our local dependencies. After that we go to the .angular-cli.json file and, in the app configuration, section we add the "budgets": setting. Where we go from here depends on our specific needs, but here are some common scenarios that you might find useful for your case:
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With