-2

I made an Angular 5 application and when I run ng serve and tries to open it in browser, it take 20-30 seconds to open because vendor.bundle.js is 48MB.

Is there any way to minimize it while using compression or another option?

p.s. I can't use ng build because I am using Docker and Gitlab CI/CD so the only possible way to make it run is by ng serve i guess.

TimeFrame
  • 363
  • 2
  • 7
  • 16
  • using `ng build` should package the whole app smaller as it builds it for use rather than dev testing – mast3rd3mon Nov 06 '18 at 09:04
  • @mast3rd3mon yes but as I said, I need to use Gitlab CI/CD and Docker, and what I've seen so far the only way to make it run on Docker with Gitlab CI/CD is with `ng serve` – TimeFrame Nov 06 '18 at 09:06
  • ng serve never keeps the compiled files, they are temporary, so unless docker can build angular apps, yiu need to use ng build – mast3rd3mon Nov 06 '18 at 09:07
  • @mast3rd3mon so it means that the only way to minimize is to use `ng build` right? – TimeFrame Nov 06 '18 at 09:20
  • there are probably other ways but you should be building your application anyway – mast3rd3mon Nov 06 '18 at 09:20
  • @mast3rd3mon ok then thank you. I'll try to find a way to run it on Docker using `ng build` – TimeFrame Nov 06 '18 at 09:22

1 Answers1

0

Find a way to use ng build instead of ng serve, you need it at all costs.

After that, if your vendor file is still big, take a look at tools like source-map-explorer as described in How to reduce vendor/script bundle.js in Angular 5 and consider adding gzip compression to your HTTP server (likely Apache or Nginx)

Guerric P
  • 30,447
  • 6
  • 48
  • 86