You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The build artifacts will be stored in the `dist/` directory.
122
120
123
-
### Environments
121
+
### Build Targets and Environment Files
124
122
125
-
At build time, the `src/app/environment.ts` will be replaced by either
126
-
`config/environment.dev.ts` or `config/environment.prod.ts`, depending on the
127
-
current cli environment. The resulting file will be `dist/app/environment.ts`.
123
+
A build can specify both a build target (`development` or `production`) and an
124
+
environment file to be used with that build. By default, the development build
125
+
target is used.
128
126
129
-
Environment defaults to `dev`, but you can generate a production build via
130
-
the `-prod` flag in either `ng build -prod` or `ng serve -prod`.
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
129
+
provided to the `--environment` flag.
130
+
131
+
These options also apply to the serve command. If you do not pass a value for `environment`,
132
+
it will default to `dev` for `development` and `prod` for `production`.
133
+
134
+
```bash
135
+
# these are equivalent
136
+
ng build --target=production --environment=prod
137
+
ng build --prod --env=prod
138
+
ng build --prod
139
+
# and so are these
140
+
ng build --target=development --environment=dev
141
+
ng build --dev --e=dev
142
+
ng build --dev
143
+
ng build
144
+
```
131
145
132
146
You can also add your own env files other than `dev` and `prod` by creating a
133
-
`config/environment.{NAME}.ts` and use them by using the `--env=NAME`
147
+
`src/app/environments/environment.{NAME}.ts` and use them by using the `--env=NAME`
134
148
flag on the build/serve commands.
135
149
136
150
### Bundling
@@ -144,13 +158,7 @@ all dependencies into a single file, and make use of tree-shaking techniques.
144
158
ng test
145
159
```
146
160
147
-
Tests will execute after a build is executed via [Karma](http://karma-runner.github.io/0.13/index.html), and it will automatically watch your files for changes.
148
-
149
-
You can run tests a single time via `--watch=false`, and turn off building of the app via `--build=false` (useful for running it at the same time as `ng serve`).
150
-
151
-
**WARNING:** On Windows, `ng test` is hitting a file descriptor limit (see https://github.com/angular/angular-cli/issues/977).
152
-
The solution for now is to instead run `ng serve` and `ng test --build=false` in separate console windows.
153
-
161
+
Tests will execute after a build is executed via [Karma](http://karma-runner.github.io/0.13/index.html), and it will automatically watch your files for changes. You can run tests a single time via `--watch=false`.
154
162
155
163
### Running end-to-end tests
156
164
@@ -204,7 +212,7 @@ You can modify the these scripts in `package.json` to run whatever tool you pref
204
212
205
213
### Support for offline applications
206
214
207
-
The index.html file includes a commented-out code snippet for installing the angular2-service-worker. This support is experimental, please see the angular/mobile-toolkit project and https://mobile.angular.io/ for documentation on how to make use of this functionality.
215
+
Angular-CLI includes support for offline applications via the `--mobile` flag on `ng new`. Support is experimental, please see the angular/mobile-toolkit project and https://mobile.angular.io/ for documentation on how to make use of this functionality.
208
216
209
217
### Commands autocompletion
210
218
@@ -231,19 +239,44 @@ source ~/.bash_profile
231
239
232
240
### CSS Preprocessor integration
233
241
234
-
We support all major CSS preprocessors:
242
+
Angular-CLI supports all major CSS preprocessors:
235
243
- sass (node-sass)
236
244
- less (less)
237
245
- compass (compass-importer + node-sass)
238
246
- stylus (stylus)
239
247
240
-
To use one just install for example `npm install node-sass` and rename `.css` files in your project to `.scss` or `.sass`. They will be compiled automatically.
248
+
To use these prepocessors simply add the file to your component's `styreUrl`:
249
+
250
+
```
251
+
@Component({
252
+
moduleId: module.id,
253
+
selector: 'app-root',
254
+
templateUrl: 'app.component.html',
255
+
styleUrls: ['app.component.scss']
256
+
})
257
+
export class AppComponent {
258
+
title = 'app works!';
259
+
}
260
+
```
261
+
262
+
When generating a new project you can also define which extention you want for
263
+
style files:
241
264
242
-
The `Angular2App`'s options argument has `sassCompiler`, `lessCompiler`, `stylusCompiler` and `compassCompiler` options that are passed directly to their respective CSS preprocessors.
265
+
```bash
266
+
ng new sassy-project --style=sass
267
+
268
+
```
243
269
244
270
### 3rd Party Library Installation
245
271
246
-
The installation of 3rd party libraries are well described at our [Wiki Page](https://github.com/angular/angular-cli/wiki/3rd-party-libs)
272
+
Simply install your library via `npm install lib-name` and import it in your code.
273
+
274
+
If the library does not include typings, you can install them using npm:
275
+
276
+
```bash
277
+
npm install moment
278
+
npm install @types/moment
279
+
```
247
280
248
281
### Updating angular-cli
249
282
@@ -313,6 +346,8 @@ the local `angular-cli` from the project which was fetched remotely from npm.
313
346
Now the `angular-cli` you cloned before is in three places:
314
347
The folder you cloned it into, npm's folder where it stores global packages and the `angular-cli` project you just created.
315
348
349
+
You can also use `ng new foo --link-cli` to automatically link the `angular-cli` package.
350
+
316
351
Please read the official [npm-link documentation](https://www.npmjs.org/doc/cli/npm-link.html)
317
352
and the [npm-link cheatsheet](http://browsenpm.org/help#linkinganynpmpackagelocally) for more information.
0 commit comments