After making some changes in my TypeScript files, each build takes over 20 minutes.
I run this command: ng build --output-path=..\\..\\static\\angularjs
.
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,
You can use node parameter --max_old_space_size
like
node --max_old_space_size=4096 ./node_modules/.bin/ngbuild --prod --build-optimizer
But I prefer to set it up via environment:
NODE_OPTIONS=--max-old-space-size=4096
It speedup our build process on CI pipeline twice.
According to https://github.com/angular/angular-cli/issues/6795 using --build-optimizer=false
speeds up the build.
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
While in dev mode you can change this flag for your development to
"buildOptimizer": false
This worked for me . Angular 7 .
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.