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

+2-2
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

+2-2
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

+2-2
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

+1-1
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

+33-3
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

+5-5
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

+1-1
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

+1-1
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

+1-1
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

+4-4
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

examples/cli/overlay/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CLI: --client-overlay option
22

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

77
## What Should Happen

examples/cli/progress/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CLI: Progress Option
22

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

77
## What Should Happen

examples/cli/public-protocol/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CLI: Public Option Protocol
22

33
```console
4-
npm run webpack-dev-server
4+
npx webpack serve
55
```
66

77
_NOTE: replace `<insert local ip>` with your local IP Address._

examples/cli/public/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# CLI: Public Option
22

33
```console
4-
npm run webpack-dev-server -- --open-target --host 0.0.0.0 --public <insert local ip>:8080
4+
npx webpack serve --open-target --host 0.0.0.0 --public <insert local ip>:8080
55
```
66

77
_NOTE: replace `<insert local ip>` with your local IP Address._

examples/cli/watch-static/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Watching a single directory
44

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

99
### What Should Happen
@@ -26,13 +26,13 @@ module.exports = {
2626
```
2727

2828
```console
29-
npm run webpack-dev-server -- --open-target
29+
npx webpack serve --open-target
3030
```
3131

3232
or via CLI only:
3333

3434
```console
35-
npm run webpack-dev-server -- --static assets --static css --open-target
35+
npx webpack serve --static assets --static css --open-target
3636
```
3737

3838
### What Should Happen

examples/general/config-array/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This example demonstrates using a `webpack` config containing an array of configs.
44

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

99
## What Should Happen

examples/general/config-promise/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This example demonstrates using `webpack-dev-server` with a `webpack` config tha
44
returns a `Promise`.
55

66
```console
7-
npm run webpack-dev-server -- --open
7+
npx webpack serve --open-target
88
```
99

1010
## What Should Happen

examples/general/proxy-advanced/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This example demonstrates a user case whereby the app proxies all urls that star
66
`http://jsonplaceholder.typicode.com/users`.
77

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

1212
## What should happen

examples/general/proxy-hot-reload/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# General: Proxy Hot Reload
22

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

77
Enables hot reloading for proxy config. If function is provided instead of

examples/general/proxy-simple/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# General: Simple Proxy
22

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

77
In `webpack.config.js` there is a very simple configuration for a proxy. Note that this only works when proxying to a direct ip address. See the proxy-advanced example if you want to proxy to a domain.

examples/general/universal-config/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This example demonstrates using a `webpack` config containing a `target: web` config and `target:node` config.
44

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

99
## What Should Happen

examples/general/webworker/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This example demonstrates using a WebWorker within an app run by `webpack-dev-server`.
44

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

99
## What should happen

examples/run-example.js

-10
This file was deleted.

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"pretest": "npm run lint",
3030
"prepare": "npm run build:client && husky install",
3131
"build:client": "rimraf ./client/* && babel client-src/ --out-dir client/ --ignore \"webpack.config.js\" && webpack --config client/webpack.config.js",
32-
"webpack-dev-server": "node examples/run-example.js",
3332
"release": "standard-version"
3433
},
3534
"dependencies": {

0 commit comments

Comments
 (0)