|
3 | 3 | You may choose to wish to change the host and port on which `webpack-dev-server`
|
4 | 4 | will run. The `host` and `port` options allow for that.
|
5 | 5 |
|
6 |
| -## IPv4 |
| 6 | +## host |
| 7 | + |
| 8 | +### IPv4 |
7 | 9 |
|
8 | 10 | ```console
|
9 | 11 | npx webpack serve --open-target --port 5000 --host 0.0.0.0
|
10 | 12 | ```
|
11 | 13 |
|
12 |
| -## IPv6 |
| 14 | +### IPv6 |
13 | 15 |
|
14 | 16 | _This also works with IPv6_
|
15 | 17 |
|
16 | 18 | ```console
|
17 | 19 | npx webpack serve --open-target --port 5000 --host ::
|
18 | 20 | ```
|
19 | 21 |
|
20 |
| -## local-ip |
| 22 | +### local-ip |
21 | 23 |
|
22 | 24 | 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.
|
23 | 25 |
|
24 | 26 | ```console
|
25 | 27 | npx webpack serve --open-target --port 5000 --host local-ip
|
26 | 28 | ```
|
27 | 29 |
|
28 |
| -## local-ipv4 |
| 30 | +### local-ipv4 |
29 | 31 |
|
30 | 32 | Specifying `local-ipv4` as `host` will try to resolve the `host` option as your local `IPv4` address.
|
31 | 33 |
|
32 | 34 | ```console
|
33 | 35 | npx webpack serve --open-target --port 5000 --host local-ipv4
|
34 | 36 | ```
|
35 | 37 |
|
36 |
| -## local-ipv6 |
| 38 | +### local-ipv6 |
37 | 39 |
|
38 | 40 | Specifying `local-ipv6` as `host` will try to resolve the `host` option as your local `IPv6` address.
|
39 | 41 |
|
40 | 42 | ```console
|
41 | 43 | npx webpack serve --open-target --port 5000 --host local-ipv6
|
42 | 44 | ```
|
43 | 45 |
|
44 |
| -## What Should Happen |
| 46 | +#### What Should Happen |
45 | 47 |
|
46 | 48 | 1. The script should open `http://0.0.0.0:5000/` if specifying the IPv4 option,
|
47 | 49 | or `http://[::]:5000/` for IPv6, in your default browser.
|
48 | 50 | 2. You should see the text on the page itself change to read `Success!`.
|
| 51 | + |
| 52 | +## port |
| 53 | + |
| 54 | +### specific port |
| 55 | + |
| 56 | +Tell the server to connect to a specific port with the following: |
| 57 | + |
| 58 | +```console |
| 59 | +npx webpack serve --open-target --port 9000 |
| 60 | +``` |
| 61 | + |
| 62 | +#### What Should Happen |
| 63 | + |
| 64 | +1. The script should open `http://localhost:9000/` in your default browser. |
| 65 | +2. You should see the text on the page itself change to read `Success!`. |
| 66 | + |
| 67 | +### auto |
| 68 | + |
| 69 | +Specifying `auto` as `port` will try to connect the server to the default port `8080` and if not available it will automatically search for another free port. |
| 70 | + |
| 71 | +```console |
| 72 | +npx webpack serve --open-target --port auto |
| 73 | +``` |
| 74 | + |
| 75 | +#### What Should Happen |
| 76 | + |
| 77 | +1. The script should open `http://localhost:8080/` in your default browser. |
| 78 | +2. You should see the text on the page itself change to read `Success!`. |
| 79 | +3. Keep the server open and switch to a new terminal window. |
| 80 | +4. Run the script once again. |
| 81 | +5. The script should open `http://localhost:8081/` (or any other port if it is not free) in your default browser. |
0 commit comments