Angular › Angular CLI & Project Structure
How would you use Angular CLI commands to build your project for production and analyze the resulting bundle size?
AdvancedAnswer
Running ng build with the production configuration creates an optimized version of your app with smaller file sizes, and tools like the source-map-explorer package let you visualize exactly which parts of your code are taking up the most space in the final bundle, helping you find opportunities to reduce it.
ng build --configuration production
npx source-map-explorer dist/my-app/*.js
// opens a visual chart showing which packages take up the most spaceReal-world example A team discovers a large unused charting library was accidentally being included in their main bundle, using source-map-explorer to visualize the bundle after a production build, and removes it to significantly reduce load time.