Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to speed up the Angular build process

After making some changes in my TypeScript files, each build takes over 20 minutes. I run this command: ng build --output-path=..\..\static\angularjs.

If I run it in Microsoft PowerShell, it needs 25 - 30 seconds. This is a lot of time.

Enviroment

  • Windows 10
  • 8 GB-Ram
  • PyCharm 64
  • MS PowerShell

How can I speed this up?

like image 754
michael-mammut Avatar asked Jul 21 '17 16:07

michael-mammut


People also ask

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.

What is build optimizer Angular?

Created by the Angular team, Build Optimizer is a tool that further optimizes Angular Webpack builds. It identifies code that can be removed at build time without side effects. For instance, Build Optimizer can remove Angular decorators like @Component from AOT builds.

Does ng serve do ng build?

The ng build command writes generated build artifacts to the output folder (by default is -dist/). The ng serve command does not write build and it builds artifacts from memory instead for a faster development experience. This command builds your app and deploys it.

What is NG build -- AOT?

The ng build command with the --prod meta-flag (ng build --prod) compiles with AOT by default. Why compile with AOT? With AOT, the browser downloads a pre-compiled version of the application. The browser loads executable code so it can render the application immediately, without waiting to compile the app first.


1 Answers

My app took 28secs to build, but I've reduced the time to 9secs. Usings this flag

ng build --source-map=false 

you can see the difference in time comparing the time:

ng build --stats-json   ng build --stats-json --source-map=false 

source map is intended only for debugging, Hope it helps

like image 88
Mauricio De La Quintana Avatar answered Sep 19 '22 07:09

Mauricio De La Quintana