I am using Angular CLI to build an app for production using the --prod
switch.
The bundle is created in the dist directory.
Is there a way to know which classes and functions have been actually put in the bundle after tree-shacking and all other steps?
相关问题
- Angular RxJS mergeMap types
- npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fs
- How to update placeholder text in ng2-smart-table?
- How to instantiate Http service in main.ts manuall
- Angular: ngc or tsc?
相关文章
- angular脚手架在ie9+下兼容问题
- angular 前端项目 build 报错 "Cannot find module 'le
- Angular Material Stepper causes mat-formfield to v
- After upgrade to Angular 9 cannot find variable in
- is there any difference between import { Observabl
- Suppress “Circular dependency detected” suppress w
- How can you get current positional information abo
- Angular material table not showing data
Since Angular console 7.4, there is a new way analyzing your Angular bundles.
ng add @nrwl/schematics
(this is just an extended angular workspace, but it works with the default angular workspace, too).And that's it. The output is the following. It contains the bundle size and all parts of the bundle. You can select the file you want to analyze (main/polyfills/1/etc). It will display that pie for each of that files. Pretty detailed and easy to use.
You can use webpack-bundle-analyzer to inspect your bundles.
npm install webpack-bundle-analyzer --save-dev
modify your
package.json
scripts
section with"analyze": "ng build --prod --stats-json && webpack-bundle-analyzer dist/stats.json"
npm run analyze
You can checkout this repo it is just a simple angular app that demonstrates how to implement lazy loading and it has webpack-bundle-analyzer already setup as above.
Also you can configure Angular CLI budgets to monitor your bundles size.
UPDATE:
Also with @ngx-builders/analyze you can do:
UPDATE:
In case if you are using angular console now it has bundle analyzing feature built-in also bear in mind that
stats.json
path might be different for each project stated by @Klaster_1 in comments.