I am trying to increase Angular Build production speed with command below, Ran the following command, however no improvement in build time, still at 14 min. Is the --prod command making it ignore the max old size space? is the script correct? We are running this in Azure Devops Agents, this how it appears in log
node --max-old-space-size=12288 ./node_modules/@angular/cli/bin/ng build --prod --output-hashing none
Should command for max-old-space-size be relocated in angular.json configurations production section?
Improving production build time for Angular 7 application
This is package.json file:
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "node --max-old-space-size=12288 ./node_modules/@angular/cli/bin/ng build --prod",
"prod": "node --max-old-space-size=12288 ./node_modules/@angular/cli/bin/ng build --prod --output-hashing none",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
Hey according to the documentation you can optimize you builds with
Lazy loading. only loading the application modules that absolutely must be present when the app starts. Configure the Angular Router to defer loading of all other modules (and their associated code)
Enabling the --prod mode on your build command, ;) of course. You can then inspect the bundle size using a library called source-map-explorer
npm install source-map-explorer --save-dev
Build your app for production including the source maps
ng build --prod --source-map
List the generated bundles in the dist/ folder.
ls dist/*.bundle.js
Run the explorer to generate a graphical representation of one of the bundles. The following example displays the graph for the main bundle.
node_modules/.bin/source-map-explorer dist/main.*.bundle.js
You can get more info at the angular docs here
Change your angular cli version
npm i --save-dev @anguler/cli@1.7.0-rc.0
This is the normal build time typically getting by build agent ins Azure devops for Angular 7 & 8. setting up node --max-old-space-size=12288 would give you extended memory allocation for build process. its not reduce the build time. yes this command work in azure.
With Angular 9 release, they have introduce Angular Ivy Build engine and its considerably decrease build time I have upgrade my solution to angular 9 . After that Devops build time reduce by around 60%. So try to update angular 8 and then to 9. This would give you guide for this migration Angula migration guide