Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions docs/documentation/stories/configure-hmr.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Next we need to update the bootstrap process of our app to enable the
Create a file called `src/environments/environment.hmr.ts` with the following contents:

```typescript

export const environment = {
production: false,
hmr: true
Expand All @@ -40,21 +39,33 @@ export const environment = {
};
```

Update `angular.json` to include an hmr build configuration as explained [here](./stories-application-environments)
and add a configuration within serve to enable hmr.

Update `angular.json` to include an hmr environment as explained [here](./application-environments) and add a configuration within serve to enable hmr.
Change the `myapp` reference accordingly...

```json
"serve": {
"configuration": {
"build": {
...
"configurations": {
...
"hmr": {
"hmr": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.hmr.ts"
}
],
]
}
}
},
"serve": {
...
"configurations": {
...
"hmr": {
"browserTarget": "myapp:build:hmr",
"hmr": true
}
}
}
Expand Down Expand Up @@ -138,6 +149,15 @@ if (environment.hmr) {
}
```

Run `ng build`. If it outputs `error TS2304: Cannot find name 'module'`,
then add node types to `src/tsconfig.app.json`:

```json
"compilerOptions": {
...
"types": ["node"]
}
```

### Starting the development environment with HMR enabled

Expand All @@ -155,4 +175,3 @@ When starting the server Webpack will tell you that it’s enabled:

Now if you make changes to one of your components they changes should be visible automatically without a complete browser refresh.