Skip to content

Commit fd5a3f7

Browse files
authored
docs: update examples (#3326)
1 parent b8285b1 commit fd5a3f7

File tree

24 files changed

+66
-47
lines changed

24 files changed

+66
-47
lines changed

examples/cli/bonjour/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ is started.
66
To run this example, run this command in your console or terminal:
77

88
```console
9-
npm run webpack-dev-server -- --bonjour
9+
npx webpack serve --bonjour
1010
```
1111

1212
## What Should Happen
@@ -33,7 +33,7 @@ module.exports = {
3333
```
3434

3535
```console
36-
npm run webpack-dev-server -- --config webpack.config.js
36+
npx webpack serve --config webpack.config.js
3737
```
3838

3939
## What Should Happen

examples/cli/compression/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It is enabled by default.
1010
To run this example, run this command in your console or terminal:
1111

1212
```console
13-
npm run webpack-dev-server -- --open-target --compress
13+
npx webpack serve --open-target --compress
1414
```
1515

1616
### What should happen
@@ -25,7 +25,7 @@ npm run webpack-dev-server -- --open-target --compress
2525
To run this example, run this command in your console or terminal:
2626

2727
```console
28-
npm run webpack-dev-server -- --open --no-compress
28+
npx webpack serve --open --no-compress
2929
```
3030

3131
### What should happen

examples/cli/default/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
This example demonstrates how to use `webpack-dev-server`.
44

55
```console
6-
npm run webpack-dev-server -- --open-target
6+
npx webpack serve --open-target
77
```
88

99
To run your app using an alternative config, use:
1010

1111
```console
12-
npm run webpack-dev-server -- --open-target --config alternative.config.js
12+
npx webpack serve --open-target --config alternative.config.js
1313
```
1414

1515
## What Should Happen

examples/cli/history-api-fallback/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ support in `webpack-dev-server`, effectively asking the server to fallback to
55
`index.html` in the event that a requested resource cannot be found.
66

77
```shell
8-
npm run webpack-dev-server -- --open-target --history-api-fallback
8+
npx webpack serve --open-target --history-api-fallback
99
```
1010

1111
_Note: some URLs don't work by default. For example; if the url contains a dot.

examples/cli/hmr/README.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
Hot Module Replacement (HMR) exchanges, adds, or removes modules while an
44
application is running, without a full reload of the page.
55

6+
## --hot
7+
68
To run this example, run this command in your console or terminal:
79

810
```console
9-
npm run webpack-dev-server -- --open-target --hot
11+
npx webpack serve --open-target --hot
1012
```
1113

1214
## What Should Happen
@@ -18,8 +20,8 @@ npm run webpack-dev-server -- --open-target --hot
1820
In the devtools console you should see:
1921

2022
```
21-
[WDS] App updated. Recompiling...
22-
[WDS] App hot update...
23+
[webpack-dev-server] App updated. Recompiling...
24+
[webpack-dev-server] App hot update...
2325
[HMR] Checking for updates on the server...
2426
[HMR] Updated modules:
2527
[HMR] - ./example.js
@@ -28,3 +30,31 @@ In the devtools console you should see:
2830

2931
You should also see the text on the page itself change to match your edits in
3032
`example.js`.
33+
34+
## --hot only
35+
36+
Enables Hot Module Replacement without page refresh as a fallback in case of build failures.
37+
38+
```console
39+
npx webpack serve --open-target --hot only
40+
```
41+
42+
## What Should Happen
43+
44+
1. The script should open `http://localhost:8080/` in your default browser.
45+
2. In your editor, open `example.js` and change `const` keyword to `constt` to cause build error.
46+
3. Open the console in your browser's devtools.
47+
4. Revert the change in step 2 and change any part of the `innerHTML` string.
48+
49+
In the devtools console you should see:
50+
51+
```
52+
[webpack-dev-server] App updated. Recompiling...
53+
[webpack-dev-server] App hot update...
54+
[HMR] Checking for updates on the server...
55+
⚠️ Ignored an update to unaccepted module ./example.js -> ./app.js
56+
[HMR] Nothing hot Updated.
57+
[HMR] App is up to date.
58+
```
59+
60+
5. Refresh the page and see the text on the page itself change to match your edits in `example.js`.

examples/cli/host-and-port/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,39 @@ will run. The `host` and `port` options allow for that.
66
## IPv4
77

88
```console
9-
npm run webpack-dev-server -- --open-target --port 5000 --host 0.0.0.0
9+
npx webpack serve --open-target --port 5000 --host 0.0.0.0
1010
```
1111

1212
## IPv6
1313

1414
_This also works with IPv6_
1515

1616
```console
17-
npm run webpack-dev-server -- --open-target --port 5000 --host ::
17+
npx webpack serve --open-target --port 5000 --host ::
1818
```
1919

2020
## local-ip
2121

2222
Specifying `local-ip` as `host` will try to resolve the `host` option as your local `IPv4` address if available, if `IPv4` is not available it will try to resolve your local `IPv6` address.
2323

2424
```console
25-
npm run webpack-dev-server -- --open-target --port 5000 --host local-ip
25+
npx webpack serve --open-target --port 5000 --host local-ip
2626
```
2727

2828
## local-ipv4
2929

3030
Specifying `local-ipv4` as `host` will try to resolve the `host` option as your local `IPv4` address.
3131

3232
```console
33-
npm run webpack-dev-server -- --open-target --port 5000 --host local-ipv4
33+
npx webpack serve --open-target --port 5000 --host local-ipv4
3434
```
3535

3636
## local-ipv6
3737

3838
Specifying `local-ipv6` as `host` will try to resolve the `host` option as your local `IPv6` address.
3939

4040
```console
41-
npm run webpack-dev-server -- --open-target --port 5000 --host local-ipv6
41+
npx webpack serve --open-target --port 5000 --host local-ipv6
4242
```
4343

4444
## What Should Happen

examples/cli/multi-compiler/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
`webpack-dev-server` should be able to compile multiple webpack configs.
44

55
```shell
6-
npm run webpack-dev-server -- --open-target
6+
npx webpack serve --open-target
77
```
88

99
## What Should Happen

examples/cli/node-false/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CLI: Webpack `node` Option
22

33
```shell
4-
npm run webpack-dev-server -- --open-target
4+
npx webpack serve --open-target
55
```
66

77
## What should happen

examples/cli/open-target-multiple/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CLI: Open Target Option (Multiple)
22

33
```console
4-
npm run webpack-dev-server -- --open-target example1.html --open-target example2.html
4+
npx webpack serve --open-target example1.html --open-target example2.html
55
```
66

77
Some applications may consist of multiple pages. During development it may

examples/cli/open-target/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@
33
Open browser:
44

55
```
6-
npm run webpack-dev-server -- --open-target
6+
npx webpack serve --open-target
77
```
88

99
Open specific page in browser:
1010

1111
```
12-
npm run webpack-dev-server -- --open-target /example.html#page1
12+
npx webpack serve --open-target /example.html#page1
1313
```
1414

1515
Open specific browser:
1616

1717
```
18-
npm run webpack-dev-server -- --open-app firefox
18+
npx webpack serve --open-app firefox
1919
```
2020

2121
Open specific page in specific browser:
2222

2323
```
24-
npm run webpack-dev-server -- --open-target example.html#page1 --open-app firefox
24+
npx webpack serve --open-target example.html#page1 --open-app firefox
2525
```
2626

2727
Some applications may consist of multiple pages. During development it may

0 commit comments

Comments
 (0)