Angular CLI output - how to analyze bundle files

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Angular CLI output - how to analyze bundle files



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?


--prod




1 Answer
1



You can use webpack-bundle-analyzer to inspect your bundles.



npm install webpack-bundle-analyzer --save-dev


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"


package.json


scripts


"analyze": "ng build --prod --stats-json && webpack-bundle-analyzer dist/stats.json"



npm run analyze


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.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard