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
Update documentation for the hmr story to show proper
configurations in angular.json and src/tsconfig.app.json.
Closesangular#11028, angular#10668, angular#10663
Copy file name to clipboardExpand all lines: docs/documentation/stories/configure-hmr.md
+41-27Lines changed: 41 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -15,40 +15,39 @@ Next we need to update the bootstrap process of our app to enable the
15
15
Create a file called `src/environments/environment.hmr.ts` with the following contents:
16
16
17
17
```typescript
18
-
19
18
exportconst environment = {
20
-
production: false,
21
-
hmr: true
19
+
production: false,
20
+
hmr: true
22
21
};
23
22
```
24
23
25
24
Update `src/environments/environment.prod.ts` and add the `hmr: false` flag to the environment:
26
25
27
26
```typescript
28
27
exportconst environment = {
29
-
production: true,
30
-
hmr: false
28
+
production: true,
29
+
hmr: false
31
30
};
32
31
```
33
32
34
33
Update `src/environments/environment.ts` and add the `hmr: false` flag to the environment:
35
34
36
35
```typescript
37
36
exportconst environment = {
38
-
production: false,
39
-
hmr: false
37
+
production: false,
38
+
hmr: false
40
39
};
41
40
```
42
41
43
-
44
-
Update `angular.json` to include an hmr environment as explained [here](./application-environments) and add a configuration within serve to enable hmr.
42
+
Update `angular.json` to include an hmr environment as explained [here](./application-environments)
43
+
and add configurations within build and serve to enable hmr. Note that `<project-name>` here
44
+
represents the name of the project you are adding this configuration to in `angular.json`.
45
45
46
46
```json
47
-
"serve": {
48
-
"configuration": {
47
+
"build": {
48
+
"configurations": {
49
49
...
50
50
"hmr": {
51
-
"hmr": true,
52
51
"fileReplacements": [
53
52
{
54
53
"replace": "src/environments/environment.ts",
@@ -57,16 +56,37 @@ Update `angular.json` to include an hmr environment as explained [here](./applic
57
56
],
58
57
}
59
58
}
59
+
},
60
+
...
61
+
"serve": {
62
+
"configurations": {
63
+
...
64
+
"hmr": {
65
+
"hmr": true,
66
+
"browserTarget": "<project-name>:build:hmr"
67
+
}
68
+
}
60
69
}
61
70
```
62
71
72
+
Add the necessary types to `src/tsconfig.app.json`
73
+
74
+
````json
75
+
{
76
+
...
77
+
"compilerOptions": {
78
+
...
79
+
"types": ["node"]
80
+
},
81
+
}
82
+
63
83
Run `ng serve` with the flag `--configuration hmr` to enable hmr and select the new environment:
64
84
65
85
```bash
66
86
ng serve --configuration hmr
67
-
```
87
+
````
68
88
69
-
Create a shortcut for this by updating `package.json` and adding an entry to the script object:
89
+
Create a shortcut for this by updating `package.json` and adding an entry to the script object:
70
90
71
91
```json
72
92
"scripts": {
@@ -75,40 +95,39 @@ Create a shortcut for this by updating `package.json` and adding an entry to th
75
95
}
76
96
```
77
97
78
-
79
98
### Add dependency for @angularclass/hmr and configure app
80
99
81
100
In order to get HMR working we need to install the dependency and configure our app to use it.
82
101
83
-
84
102
Install the `@angularclass/hmr` module as a dev-dependency
85
103
86
104
```bash
87
105
$ npm install --save-dev @angularclass/hmr
88
106
```
89
107
90
-
91
108
Create a file called `src/hmr.ts` with the following content:
0 commit comments