Angular CLI - why is the <ng serve> package better than the <ng build>?
Running a series of Angular CLI commands to create a standard base project:
ng new project cd project ng build --prod
... as a result, I get a generated dist
folder with several packages. The largest is called vendor.[hash].js
and the size is about 855kB
.
However, if I run ng serve --prod
instead:
ng new project cd project ng serve --prod
... I see that the weight of localhost:4200
loaded by the provider is around 300kB
using the Chrome console.
Why is this happening? Is there a way to achieve a second result without ng serve
, but rather with ng build
?
I tested this in my environment:
ng build --prod = main. [hash] .js = 792KB.
bg serve --prod = main. [hash] .js = 863KB.
$ ng --version angular-cli: 1.0.0-beta.19-3 node: 7.0.0 os: win32 x64
ng serve generates a slightly smaller cache file because it is temporary.
Update your ng cli and check again.