angular-cli: ng build --prod --aot --output-hashing none stuck at chunk asset optimization after Angular V 5 upgrade

After Upgrading to Angular Version 5 the aot compilation seems to be stuck at 92 % chunk Optimisation for ages. and Completes after a full 4 mins

Date: 2017-11-03T13:54:26.604Z
Hash: 35cf6c5f7a300435f807
Time: 222890ms
chunk {0} 0.chunk.js () 16.7 kB  [rendered]
chunk {1} main.bundle.js (main) 2.56 MB [initial] [rendered]
chunk {2} polyfills.bundle.js (polyfills) 63.8 kB [initial] [rendered]
chunk {3} styles.bundle.css (styles) 296 kB [initial] [rendered]
chunk {4} inline.bundle.js (inline) 1.36 kB [entry] [rendered]

Any reason for this slowness

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 15
  • Comments: 25 (2 by maintainers)

Most upvoted comments

Angular CLI: 1.6.1 Node: 8.9.3 OS: win32 x64 Angular: 5.1.1

ng build --prod --output-hashing none

Time: 4181285ms ( 70 mins)

ng build --prod --output-hashing none --build-optimizer false

Time: 112442ms (< 2 mins)

if you want to speedup the build process then you have to increase the memory.

For making build faster in production, we need to set the memory size in local machine Steps 1:- C:\Users<username>\AppData\Roaming\npm
Steps 2:- Replace the ng.cmd file(attached here)

So by doing this, it will rectify “Java Script heap out of memory” error as well.

aaa

@filipesilva This build --prod is still extremely slow, Time: 261184ms

@abhinavJai… Thank you it works for me.

I was having the same issue (my build was stuck at 92% and taking around 18 minutes to complete…) I increased memory allocation for node and also disabled some options in the build command this way:

node --max_old_space_size=5048 “%~dp0..@angular\cli\bin\ng” build --prod --source-map false --build-optimizer false --aot false

This way my build only takes 33 seconds. Hope this help you pass that 92% chunk optimization faster.

If you’re stuck at 92%, try commenting out any [styleUrls] in your components and see if that makes a difference. I was experiencing that and switched to linked stylesheets because when I removed my [styleUrls], it completed the build.

Adding following in package.json caused build time to improve. Now same build happens in less than 20 minutes. I increased memory to 12 GB

“scripts”: { “build”: “node --max_old_space_size=12288 ./node_modules/@angular/cli/bin/ng build --prod” }

I am also facing same problem here. ng build --prod is taking more than 15 mints to build the project. I am using cli : 1.7.0 angular :5.2.0 node: 6.9.1 os: windows 10 thanks

I asked some one from the Angular team they are telling as build optimiser is enabled by default this is causing the prod build to be slower