@@ -36,6 +36,7 @@ The generated project has dependencies that require **Node 4 or greater**.
36
36
* [ Creating a Build] ( #creating-a-build )
37
37
* [ Build Targets and Environment Files] ( #build-targets-and-environment-files )
38
38
* [ Bundling] ( #bundling )
39
+ * [ Adding extra files to the build] ( #adding-extra-files-to-the-build )
39
40
* [ Running Unit Tests] ( #running-unit-tests )
40
41
* [ Running End-to-End Tests] ( #running-end-to-end-tests )
41
42
* [ Deploying the App via GitHub Pages] ( #deploying-the-app-via-github-pages )
@@ -124,8 +125,8 @@ A build can specify both a build target (`development` or `production`) and an
124
125
environment file to be used with that build. By default, the development build
125
126
target is used.
126
127
127
- At build time, ` src/app/ environments/environment.ts ` will be replaced by
128
- ` src/app/ environments/environment.{ NAME} .ts ` where ` NAME ` is the argument
128
+ At build time, ` src/environments/environment.ts ` will be replaced by
129
+ ` src/environments/environment.NAME.ts ` where ` NAME ` is the argument
129
130
provided to the ` --environment ` flag.
130
131
131
132
These options also apply to the serve command. If you do not pass a value for ` environment ` ,
@@ -143,14 +144,49 @@ ng build --dev
143
144
ng build
144
145
```
145
146
146
- You can also add your own env files other than ` dev ` and ` prod ` by creating a
147
- ` src/app/environments/environment.{NAME}.ts ` and use them by using the ` --env=NAME `
148
- flag on the build/serve commands.
147
+ You can also add your own env files other than ` dev ` and ` prod ` by doing the following:
148
+ - create a ` src/environments/environment.NAME.ts `
149
+ - add ` { NAME: 'src/environments/environment.NAME.ts' } ` to the the ` apps[0].environments ` object in ` angular-cli.json `
150
+ - use them by using the ` --env=NAME ` flag on the build/serve commands.
149
151
150
152
### Bundling
151
153
152
- Builds created with the ` -prod ` flag via ` ng build -prod ` or ` ng serve -prod ` bundle
153
- all dependencies into a single file, and make use of tree-shaking techniques.
154
+ All builds make use of bundling, and using the ` -prod ` flag in ` ng build -prod `
155
+ or ` ng serve -prod ` will also make use of uglifying and tree-shaking functionality.
156
+
157
+ ### Adding extra files to the build
158
+
159
+ The ` apps[0].additionalEntries ` array in ` angular-cli.json ` allows a user to add more files to the build.
160
+
161
+ The ` additionalEntries ` array supports two kinds of entries, with different behaviours.
162
+ - strings will be bundled together with the ` main ` bundle
163
+ - objects with ` input ` and ` output ` properties will create a new bundle which is loaded before the ` main ` bundle.
164
+
165
+ By default it looks like this:
166
+
167
+ ```
168
+ apps: [
169
+ {
170
+ //...
171
+ "additionalEntries": [
172
+ { "input": "polyfills.ts", "output": "polyfills.js" },
173
+ "scripts.ts",
174
+ "styles.css"
175
+ ],
176
+ }
177
+ ]
178
+ ```
179
+
180
+ These entries correspond to the following files in ` src/ ` :
181
+ - ` polifills.ts ` has browser polyfills needed for Angular 2. It will be
182
+ bundled separately as ` polyfills.js ` and loaded before everything else.
183
+ - ` styles.css ` allows users to add global styles and supports
184
+ [ CSS imports] ( https://developer.mozilla.org/en/docs/Web/CSS/@import ) . If the
185
+ project is created with the ` --style=sass ` option, this will be a ` .sass ` file
186
+ instead, and the same applies to ` scss/less/styl ` . It will be part of the main
187
+ bundle.
188
+ - ` scripts.ts ` allows users to add global code outside of the Angular 2 app. It
189
+ will also be part of the main bundle.
154
190
155
191
### Running unit tests
156
192
0 commit comments