Search code examples
angularnrwl

Angular bundle size not reduced using nx monorepo using --prod and --build-optimizer


I'm trying to reduce/optimise my angular bundle. The problem is that what ever I try, the files in dist are always the same size. In my case, the total dist-size is 1.6MB (main.js has a filesize of 430KB)

Here is what I do:

$> nx run build:www

and

$> nx clear-cache   
$> NX_CACHE=skip npm run build:www -- --prod --build-optimizer

I also tried without the -- whithout success. I also noticed, that NX_CACHE=skip doesn't seem to do much, thats why I added the nx clear-cache to make sure cache is cleared.

Any suggestions


Solution

  • Posting it as an answer so that it may help others:

    Please try using the below command:

    ng build --prod --aot --build-optimizer --vendor-chunk=true