Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
In this video, we'll learn to use the CLI to create and deploy a production build of our application.
Build Optimizer
The Angular Build Optimizer provides the following benefits:
- Smaller Bundles - Removes code that your app doesn't need to run.
- Class Fold - Static properties are folded into ES5 classes.
- Scrub File - Angular decorators, property decorators and constructor parameters are removed, while leaving non-Angular ones intact.
- Prefix Functions and Classes - Marks functions and classes as pure so they can optimized out when minifying code.
For more information about the Build Optimizer, see the following resources:
AOT Compilation
AOT (ahead-of-time) compilation provides the following benefits:
- Fewer Requests - Templates and styles are precompiled into the app eliminating AJAX requests to get those resources.
- Faster Rendering (i.e. app load times) - The Angular app is precompiled, so the compilation step can be eliminated with the app is loading in the browser.
- Smaller Downloads - The Angular compiler can be eliminated from the Angular framework, which is roughly half the size of the download.
- Detect Template Errors Sooner - The AOT compiler detects and reports template binding errors during the build step before users can see them.
For more information about AOT see https://angular.io/guide/aot-compiler.
Setting the Build Output Path in Configuration
As an alternative to using the ng build
command's --output-path
option, you can configure the build output path via the .angular-cli.json
configuration file's apps[].outDir
property.
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "test-app"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
Additional Learning
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up