Creating Your First Workspace
The ng new command creates a complete Angular workspace with a pre-configured build pipeline, testing setup, and development server.
Basic Usage
ng new my-app
This launches an interactive prompt asking:
- Would you like to add Angular routing? — Yes for multi-page apps
- Which stylesheet format would you like to use? — CSS, SCSS, Sass, or Less
- Do you want to enable Server-Side Rendering (SSR)? — No for most SPAs
Non-Interactive Creation
ng new my-app --routing --style=scss --ssr=false
Generated Structure
my-app/
├── angular.json # Build configuration and targets
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript compiler options
├── tsconfig.app.json # App-specific TS config
├── tsconfig.spec.json # Test-specific TS config
├── .editorconfig # Editor formatting rules
├── .gitignore
├── src/
│ ├── index.html # Entry HTML
│ ├── main.ts # Bootstrap file
│ ├── styles.css # Global styles
│ └── app/
│ ├── app.component.ts
│ ├── app.component.html
│ ├── app.component.css
│ └── app.config.ts # Standalone config (no NgModule)
└── node_modules/
Standalone vs NgModule
Modern Angular (v14+) defaults to standalone components — no AppModule required. The bootstrap happens in main.ts:
import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { AppComponent } from './app/app.component';
bootstrapApplication(AppComponent, appConfig)
.catch((err) => console.error(err));
For legacy NgModule projects, use the --no-standalone flag.
Understanding angular.json and Build Configuration
The angular.json file is the heart of your build system. It defines how the CLI compiles, serves, and tests your application.
Key Sections
{
"projects": {
"my-app": {
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/my-app",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"assets": ["src/favicon.ico", "src/assets"],
"styles": ["src/styles.css"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true
}
}
}
}
}
}
}
What Each Option Does
| Option | Purpose |
|---|---|
outputPath |
Where build artifacts are written |
index |
Entry HTML file |
browser |
Entry TypeScript file |
polyfills |
Zone.js for change detection |
tsConfig |
TypeScript config for compilation |
assets |
Static files copied to output |
styles |
Global CSS files |
budgets |
Size limits that fail the build |
Build Configurations
- production — optimized, minified, with budgets
- development — source maps, no optimization, faster builds
Switch between them:
ng build --configuration production
ng serve --configuration development
Quiz
1. What does ng new prompt you about?
2. What is the default component style in modern Angular?
3. Where is the build configuration stored?
Flashcards
Question
How do you create a new Angular project?
Click to reveal answer
Answer
ng new <app-name> — creates a workspace with routing, styles, and build config.
Question
What file configures the Angular build system?
Click to reveal answer
Answer
angular.json — defines build targets, assets, styles, budgets, and configurations.
Question
What is the default component style in Angular v14+?
Click to reveal answer
Answer
Standalone components — no NgModule required. Bootstrap via bootstrapApplication().
Revision Notes
Key Takeaways
- 1. ng new creates a complete workspace with build, test, and dev server setup
- 2. Modern Angular uses standalone components by default (no NgModule)
- 3. angular.json is the central build configuration file
- 4. Build budgets enforce bundle size limits
Interview Tips
- • Explain the difference between standalone and NgModule-based projects
- • Be ready to describe what angular.json controls
- • Mention build budgets as a production safety net
Cheat Sheet
ng new Cheat Sheet
Create project:
ng new my-app --routing --style=scss
Key files:
angular.json— build configsrc/main.ts— bootstrapsrc/app/app.config.ts— app providerssrc/app/app.component.ts— root component
Build configs:
production— optimized, minifieddevelopment— source maps, fast builds
Standalone (default):
bootstrapApplication(AppComponent, appConfig)