How to speed up the Angular build process
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
This reduced my build time to 50%
"optimization": false,
"outputHashing": "none",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"showCircularDependencies": false,
"aot": true,
"extractLicenses": false,
"statsJson": false,
"progress": false,
"vendorChunk": true,
"buildOptimizer": false,
I've found that for me, this issue was solved by using the watch
flag, i.e.
ng build --watch=true
This runs constantly, and automatically builds files only when saved. It has dropped my build time from 8 sec to <1 sec for small changes in code, since it only generates .js
files for what actually changed.
From https://angular.io/guide/deployment
The
ng build
command generates output files just once and does not serve them.The
ng build --watch
command will regenerate output files when source files change. This--watch
flag is useful if you're building during development and are automatically re-deploying changes to another server.
You should probably use ng build
with the necessary options when you are building for production so that the necessary optimizations are completed.