Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ng build -prod vs ng build --prod --build-optimizer=true

My Angular project is @Angular4.3.3

ng build -prod

Takes 77 seconds to make a build

ng build --prod --build-optimizer=true

Takes 190 seconds to make a build, No vendor chunk, less in size(but not a big difference in size though)

Chunk differences on console image: Difference between those two builds

I read Bundling & Tree-Shaking but still don't get the clear difference between builds created by those commands.

Why there are these two different ways and what is the difference in performance or any other way?

like image 276
Lahar Shah Avatar asked Sep 05 '25 03:09

Lahar Shah


1 Answers

--build-optimizer and --vendor-chunk

From Angular CLI Docs:

When using Build Optimizer the vendor chunk will be disabled by default. You can override this with --vendor-chunk=true.

Total bundle sizes with Build Optimizer are smaller if there is no separate vendor chunk because having vendor code in the same chunk as app code makes it possible for Uglify to remove more unused code.

like image 153
superandrew Avatar answered Sep 10 '25 16:09

superandrew