@@ -15,43 +15,7 @@ The build artifacts will be stored in the `dist/` directory.
15
15
16
16
All commands that build or serve your project, ` ng build/serve/e2e ` , will delete the output
17
17
directory (` dist/ ` by default).
18
- This can be disabled via the ` --no-delete-output-path ` (or ` --delete-output-path=false ` ) flag.
19
-
20
- ### Build Targets and Environment Files
21
-
22
- ` ng build ` can specify both a build target (` --target=production ` or ` --target=development ` ) and an
23
- environment file to be used with that build (` --environment=dev ` or ` --environment=prod ` ).
24
- By default, the development build target and environment are used.
25
-
26
- The mapping used to determine which environment file is used can be found in ` .angular-cli.json ` :
27
-
28
- ``` json
29
- "environmentSource" : " environments/environment.ts" ,
30
- "environments" : {
31
- "dev" : " environments/environment.ts" ,
32
- "prod" : " environments/environment.prod.ts"
33
- }
34
- ```
35
-
36
- These options also apply to the serve command. If you do not pass a value for ` environment ` ,
37
- it will default to ` dev ` for ` development ` and ` prod ` for ` production ` .
38
-
39
- ``` bash
40
- # these are equivalent
41
- ng build --target=production --environment=prod
42
- ng build --prod --env=prod
43
- ng build --prod
44
- # and so are these
45
- ng build --target=development --environment=dev
46
- ng build --dev --e=dev
47
- ng build --dev
48
- ng build
49
- ```
50
-
51
- You can also add your own env files other than ` dev ` and ` prod ` by doing the following:
52
- - create a ` src/environments/environment.NAME.ts `
53
- - add ` { "NAME": 'src/environments/environment.NAME.ts' } ` to the ` apps[0].environments ` object in ` .angular-cli.json `
54
- - use them via the ` --env=NAME ` flag on the build/serve commands.
18
+ This can be disabled via the ` --delete-output-path=false ` option.
55
19
56
20
### Base tag handling in index.html
57
21
@@ -60,34 +24,13 @@ When building you can modify base tag (`<base href="/">`) in your index.html wit
60
24
``` bash
61
25
# Sets base tag href to /myUrl/ in your index.html
62
26
ng build --base-href /myUrl/
63
- ng build --bh /myUrl/
64
27
```
65
28
66
29
### Bundling & Tree-Shaking
67
30
68
31
All builds make use of bundling and limited tree-shaking, while ` --prod ` builds also run limited
69
32
dead code elimination via UglifyJS.
70
33
71
- ### ` --dev ` vs ` --prod ` builds
72
-
73
- Both ` --dev ` /` --target=development ` and ` --prod ` /` --target=production ` are 'meta' flags, that set other flags.
74
- If you do not specify either you will get the ` --dev ` defaults.
75
-
76
- Flag | ` --dev ` | ` --prod `
77
- --- | --- | ---
78
- ` --aot ` | ` false ` | ` true `
79
- ` --environment ` | ` dev ` | ` prod `
80
- ` --output-hashing ` | ` media ` | ` all `
81
- ` --sourcemaps ` | ` true ` | ` false `
82
- ` --extract-css ` | ` false ` | ` true `
83
- ` --named-chunks ` | ` true ` | ` false `
84
- ` --build-optimizer ` | ` false ` | ` true ` with AOT and Angular 5
85
-
86
- ` --prod ` also sets the following non-flaggable settings:
87
- - Adds service worker if configured in ` .angular-cli.json ` .
88
- - Replaces ` process.env.NODE_ENV ` in modules with the ` production ` value (this is needed for some libraries, like react).
89
- - Runs UglifyJS on the code.
90
-
91
34
### ` --build-optimizer ` and ` --vendor-chunk `
92
35
93
36
When using Build Optimizer the vendor chunk will be disabled by default.
@@ -104,20 +47,6 @@ If a resource is less than 10kb it will also be inlined.
104
47
105
48
You'll see these resources be outputted and fingerprinted at the root of ` dist/ ` .
106
49
107
- ### Service Worker
108
-
109
- There is experimental service worker support for production builds available in the CLI.
110
- To enable it, run the following commands:
111
- ```
112
- npm install @angular/service-worker --save
113
- ng set apps.0.serviceWorker=true
114
- ```
115
-
116
- On ` --prod ` builds a service worker manifest will be created and loaded automatically.
117
- Remember to disable the service worker while developing to avoid stale code.
118
-
119
- Note: service worker support is experimental and subject to change.
120
-
121
50
### ES2015 support
122
51
123
52
To build in ES2015 mode, edit ` ./tsconfig.json ` to use ` "target": "es2015" ` (instead of ` es5 ` ).
0 commit comments