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

后端 未结 3 1124
天命终不由人
天命终不由人 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:37

    Build your app with sourcemaps, then use a tool like source-map-explorer that details the size of every part of library that you're using.

    Some tips with common libraries :

    • If you're using RxJS 5.5 or higher, use the .pipe(operator1(), operator2()) syntax, it significantly reduces RxJS size when you don't use many different operators
    • If you're using moment.js be sure to import only the locales you're using
    • If you're using Angular Material, be sure you don't import unused modules
    • If you're using bootstrap and SASS, import only the needed parts of .scss files

    If you didn't already do it, divide your app into lazy modules, it will reduce the size of the initial chunk.

提交回复
热议问题