Q1. How do you build an Angular application for production?
Use the command
ng build --prod
This performs optimizations: Ahead-of-Time (AOT) compilation, minification, uglification, tree-shaking, and dead code elimination. The output is in the dist/ folder, ready to be deployed to a web server.Q2. What is AOT compilation?
Ahead-of-Time (AOT) compilation compiles Angular templates and components during the build process, rather than in the browser at runtime. Benefits: faster rendering, smaller bundle sizes, fewer asynchronous requests, and template errors detected early. Production builds use AOT by default.
Q3. Where can you deploy an Angular app?
Angular apps are static and can be deployed on any web server: Apache, Nginx, or cloud platforms like Firebase Hosting, Netlify, Vercel, GitHub Pages, AWS S3, Azure Storage. Since it''s a single-page app, server must be configured to redirect all routes to index.html for client-side routing.
Q4. How do you handle routing in deployed apps?
For SPAs, you need to configure the server to return index.html for all routes (except static assets). Otherwise, direct navigation to a route gives 404. On Nginx, use try_files $uri /index.html. On Apache, use mod_rewrite. Some hosts like Netlify handle this automatically.
Q5. What environment-specific configurations should you consider?
Use environment files (environment.ts, environment.prod.ts) for API endpoints, feature flags, etc. The CLI replaces them during build. Also consider using Angular''s APP_INITIALIZER to load configuration from a server at runtime.
