Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Improving Build Time for Large Angular App

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:

  • Use a tool like depcheck in order to remove unused dependencies
  • Update all npm packages to their latest versions
  • Possibly optimizing the gruntfile?

Are 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

like image 279
User 5842 Avatar asked Apr 19 '18 03:04

User 5842


People also ask

Why is Angular app faster?

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.

Why is NG serve so slow?

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.


1 Answers

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.

like image 141
Aarsh Avatar answered Oct 25 '22 02:10

Aarsh