How to reduce vendor/script bundle.js in Angular 5

后端 未结 3 1098
天命终不由人
天命终不由人 2021-01-07 11:35

I have already used ng build -prod -aot -vc -cc -dop --buildOptimize to reduce the size of the builded app. Now this is my situation:

Is it pos

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-07 12:27

    Sorry For Late Reply. This answer will work for all newer versions of Angular.

    1. If you are using Angular Material, Then import from the specific package exporter.

    Ex:

    import {MatButtonModule} from '@angular/material/button';
    

    istead of

    import {MatButtonModule} from '@angular/material';
    
    1. Avoid using Common Material Module throughout your application.

    If you are using LazyLoading module, Import required packages in the specific module.

    I followed these steps, I got reduced bundle size from 9.0MB to 1.45MB.

    Hope it will work for you guys also :).

提交回复
热议问题