I have an Angular 2+ application that is fairly large and takes about 10 minutes to fully build.
I’d like to refactor my code base in an attempt to reduce the time taken to build.
I had some ideas but my 3 primary ones were:
depcheck
in order to remove unused dependenciesAre these some good things to do for a first attempt? What other options should I explore in order to further improve the build time?
Thanks
Angular is not generating HTML and then passing it to the browser to have it parsed, instead Angular is generating DOM data structures directly! This works much faster than building manually HTML and then passing it to the DOM for parsing.
reason: In the Angular 12 version, run ng build, and now the default is production mode. This is a welcome change because it reduces the chance of inadvertently deploying a development build to a production environment, which is much slower and much larger, making it feel like Angular is very slow.
The below command is very useful to reduce build time:
ng build --source-map=false
Source map is only needed for debugging, so if you don't want that you can surely use that command.
Another one is
--build-optimizer=false
Other than that, use AOT - ahead of time compiler. You can learn more about AOT here.
From your question, the second option might not have much effect on build time. I don't know about depcheck and optimizing gruntfile.
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