Skip to content
tezvyn:
Menu

Describe two key Angular CLI production build optimizations

Source: angular.devMediumHow cards are made

Describe two key Angular CLI production build optimizations

Tests whether you know architect targets and concrete production optimizations. Strong answers name two of: dead code elimination and minification, hashed filenames for cache busting, or disabled source maps.

What's really being asked

The interviewer wants to know if you understand the angular.json architect section controls builder targets, and that production is not just a label but a preset of aggressive optimizations. They are checking whether you can name specific behaviors of the Angular CLI build pipeline rather than giving a vague it is faster response.

The full answer

First, explain that the production configuration lives under the architect build options in angular.json and overrides the default development settings. Second, name two specific optimizations. One strong choice is dead code elimination and minification, which the CLI enables through the optimization flag set to true in production; this runs minification on scripts and optimizes styles. Another strong choice is output hashing, where the CLI rewrites filenames with content hashes for cache busting. Alternatively, mention that production disables source maps and extracts licenses to reduce payload. You do not need to list all of them, but the two you pick should be bundle-level optimizations, not just environment variable changes.

The mistakes people make

Saying that production removes console logs is not a default Angular CLI behavior unless configured. Claiming that AOT compilation is a production-only optimization is outdated because modern Angular uses AOT in both development and production. Giving only source maps are disabled as both of your two answers looks thin because it ignores the actual bundle pipeline. Also, confusing angular.json with environment files is a red flag; the interviewer expects you to talk about builder targets.

What usually comes next

The interviewer may ask how to customize these settings without ejecting, which you answer by editing the build options under the production target in angular.json. They might ask about budgets, which are size thresholds configured in the same file. They could also ask how the CLI decides which configuration to use, which leads to the defaultProject and architect target logic.

A concrete example

If you open angular.json and navigate to projects then your app then architect then build then configurations then production, you will see fields like optimization set to true and outputHashing set to all. When you run ng build --configuration production, the CLI passes these options to the builder, resulting in a dist folder where main.js becomes something like main.a3f1b2c.js and unused library code is stripped out.

Interview question

Which behavior is a default Angular CLI production build optimization configured in angular.json?

  • a.It enables Ahead-of-Time compilation exclusively for production builds
  • b.It removes all console.log statements without extra configuration
  • c.It strips unused library code and minifies scripts and stylesCorrect
  • d.It reads optimization settings from the environment.ts file
Why?

The production target in angular.json sets optimization to true, which enables dead code elimination and minification. AOT compilation is used in both development and production in modern Angular, so it is not a production-only optimization.

Just read this? Test yourself on what you have been reading.

Read the original → angular.dev

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Open roles that interview on angular — each one lists the topics its interview covers.

See open roles