Build with "ng -prod" is extremely slow
Bug Report or Feature Request (mark with an x)
- [ x] bug report -> please search issues before submitting
- [ ] feature request
Versions.
ng --version
_ _ ____ _ ___
/ \ _ __ __ _ _ | | __ _ _ __ / | | | |
/ △ \ | ' \ / _ | | | | |/ _ | '| | | | | | |
/ ___ | | | | (| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/
@angular/cli: 1.1.0
node: 7.9.0
os: win32 x64 (Win 10 Enterpirise - 16Gig , i7)
@angular/animations: 4.0.0
@angular/common: 4.0.0
@angular/compiler: 4.0.0
@angular/core: 4.0.0
@angular/forms: 4.0.0
@angular/http: 4.0.0
@angular/platform-browser: 4.0.0
@angular/platform-browser-dynamic: 4.0.0
@angular/router: 4.0.0
@angular/cli: 1.1.0
@angular/compiler-cli: 4.0.0
@angular/language-service: 4.0.0
Repro steps.
$ ng build --prod --aot=false -ec --sourcemap=false Hash: 552d9867ececa788ac3a Time: 670222ms chunk {0} polyfills.d77767cee98c83f90386.bundle.js (polyfills) 294 kB {5} [initial] [rendered] chunk {1} main.255e1d27fe4d40b56ab2.bundle.js (main) 1.51 MB {4} [initial] [rendered] chunk {2} scripts.45a4574f31d7b91e5a5e.bundle.js (scripts) 3.88 MB {5} [initial] [rendered] chunk {3} styles.ac17d766c993c4027892.bundle.css (styles) 228 bytes {5} [initial] [rendered] chunk {4} vendor.86c029ec4598fb674488.bundle.js (vendor) 8.23 MB [initial] [rendered] chunk {5} inline.750f0337ff0a9bee9813.bundle.js (inline) 0 bytes [entry] [rendered]
ng build --aot -ec -sm Hash: 24f744145f250126e699 Time: 62809ms chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 294 kB {5} [initial] [rendered] chunk {1} main.bundle.js, main.bundle.js.map (main) 3.07 MB {4} [initial] [rendered] chunk {2} scripts.bundle.js, scripts.bundle.js.map (scripts) 3.88 MB {5} [initial] [rendered] chunk {3} styles.bundle.css, styles.bundle.css.map (styles) 228 bytes {5} [initial] [rendered] chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 7.37 MB [initial] [rendered] chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
670222ms vs 62809ms is a huge difference
The log given by the failure.
There is no failure , the build takes a very long time to complete its stuck at
92% chunk asset optimization and then we have to wait for 10-15 mins to get the build completed.
I have disabled aot and sourcemaps, still the speed is very slow.
Desired functionality.
build should have similar time that to of ng build -aot
Any help and guidance to reduce will be helpful.
That's definitely a long time. Does it get smaller if you pass --build-optimizer=false?
@rezonjov @ScottSpittle @dprandzioch are you using Angular 5.x?
Partial relief with --build-optimizer=false and cli 1.6
Date: 2017-12-11T16:38:33.792Z Hash: e0338ceb997073672491 Time: 224756ms (vs 347917ms on cli 1.5) chunk {0} polyfills.5331a70a99045b106003.bundle.js (polyfills) 61.2 kB [initial] [rendered] chunk {1} styles.64f371138d201ab1d186.bundle.css (styles) 367 kB [initial] [rendered] chunk {2} main.18c151adc1813fa3ddd7.bundle.js (main) 155 kB [initial] [rendered] chunk {3} vendor.fe2debb1be57f2ba9fa3.bundle.js (vendor) 1.21 MB [initial] [rendered] chunk {4} inline.2b90f1f684dd564677bf.bundle.js (inline) 1.45 kB [entry] [rendered]
@filipesilva Angular 5.1.0 and CLI 1.6
I have the same issue. Angular 5.1.0 and CLI 1.6 On Angular 4.4, it used to be around 40 seconds. Right now, it took more than 110 seconds. Usually, it's around 300+ seconds.

@filipesilva Angular 5.1.0 and CLI 1.6 as well (I'm trying to build on MacOS Sierra). The most time waiting, I'm stuck at "92% chunk asset optimization".
@SV-efi Thanks, turning that off made a huge difference

How big are your projects btw? If you are on Linux/OSX/Git bash you can use this command to see your number of files by extension cd src/ && find -type f | sed -e 's/.*\.//' | sort | uniq -c.
We have a test project with a lot of TS files (https://github.com/filipesilva/angular-cli-test-repo) and it creates prod builds in 39m.
These are the files it has by extension:
1551 html
1 ico
8 jpg
5 json
5 png
46 scss
2637 ts
The times you all are reporting are more than that... Do any of you have a project that I can take a look at and profile?
@filipesilva I do not have a project you can look at unfortunately, but the output for the above command has provided the following;
1 eot
1 gitkeep
118 html
1 ico
4 json
1 png
91 scss
2 svg
315 ts
11 ttf
1 woff
1 woff2
@filipesilva
$ find . -type f | sed -e 's/.*\.//' | sort | uniq -c
12 css
21 eot
1 gif
1 gitkeep
90 html
1 ico
85 js
28 json
128 scss
30 svg
435 ts
21 ttf
1 vimrc
21 woff
10 woff2
@filipesilva I'm using Angular cli 1.5 and Angular 4.4.6.
Here's the result from cd src/ && find . -type f | sed -e 's/.*\.//' | sort | uniq -c
1 DS_Store
1 bak
1 gitkeep
93 html
1 ico
5 jpg
3 json
8 png
94 scss
205 ts
Current build time: 41:27 mins using ng build --prod --build-optimizer
EDIT: I remember it used to be around 15 mins 1-2 months back where the project used to be smaller and Angular 4.x and angular 1.3
C:\xampp\htdocs\ERPAn>ng build --aot Date: 2017-12-19T11:10:46.359Z Hash: e5aa9c132a0567fb1560 Time: 3094966ms
+1 one word:slow,two words: too slow 400000++ ms how to fix this ,
but i can feel project 's size more slim now
Angular 5 angular-cli 1.6.0 small project
1 ico
2 json
1 png
11 scss
38 ts
stuck at 94% asset optimization
Hash: a14d64dbd49b93516533
Time: 297631ms
chunk {0} polyfills.43a6a16e791d2caa0484.bundle.js (polyfills) 60.9 kB [initial] [rendered]
chunk {1} main.a95e3607345f8c7c70f4.bundle.js (main) 876 kB [initial] [rendered]
chunk {2} styles.b0947768ba27143612ba.bundle.css (styles) 46.3 kB [initial] [rendered]
chunk {3} inline.ed783d1e70f001f84c76.bundle.js (inline) 1.45 kB [entry] [rendered]
ng build --prod --build-optimizer=false reduce build time to 254389ms, but still too slow.
Removing "scripts": [
"../node_modules/plotly.js/dist/plotly.min.js"
], make it 54880ms, so is it cost webpack too much time processing this?
I can confirm this issue
I encountered this issue. I needed to use --build-optimizer=false option to have a build time acceptable.
Can confirm using --build-optimizer=false speeds up my build by about 10x
Can confirm as well, --build-optimizer=false takes the same time as before 5.0.
The issue is the vendor chunk is now being included the main chunk as far as I can tell [1] and uglify is churning away... Our build regressed from about 3m to >30m... I killed it before it even finished.
Passing --vendor-chunk=true resolves the issue without disabling the optimizer completely.
[1] https://github.com/angular/angular-cli/wiki/build search for build-optimizer
@elesueur bear in mind that re-enabling the vendor chunk will greatly reduce the efficacy of Build Optimizer. This was around 40% bigger bundles in our testing.