Skip to content

docs: add https example #3307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion examples/cli/compression/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to roughly 30% of its original size before the files are sent to the browser.
To run this example, run this command in your console or terminal:

```console
npm run webpack-dev-server -- --open --compress
npm run webpack-dev-server -- --open-target --compress
```

## What should happen
Expand Down
4 changes: 2 additions & 2 deletions examples/cli/default/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
This example demonstrates how to use `webpack-dev-server`.

```console
npm run webpack-dev-server -- --open
npm run webpack-dev-server -- --open-target
```

To run your app using an alternative config, use:

```console
npm run webpack-dev-server -- --open --config alternative.config.js
npm run webpack-dev-server -- --open-target --config alternative.config.js
```

## What Should Happen
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/history-api-fallback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ support in `webpack-dev-server`, effectively asking the server to fallback to
`index.html` in the event that a requested resource cannot be found.

```shell
npm run webpack-dev-server -- --open --history-api-fallback
npm run webpack-dev-server -- --open-target --history-api-fallback
```

_Note: some URLs don't work by default. For example; if the url contains a dot.
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/hmr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ application is running, without a full reload of the page.
To run this example, run this command in your console or terminal:

```console
npm run webpack-dev-server -- --open --hot
npm run webpack-dev-server -- --open-target --hot
```

## What Should Happen
Expand Down
10 changes: 5 additions & 5 deletions examples/cli/host-and-port/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ will run. The `host` and `port` options allow for that.
## IPv4

```console
npm run webpack-dev-server -- --open --port 5000 --host 0.0.0.0
npm run webpack-dev-server -- --open-target --port 5000 --host 0.0.0.0
```

## IPv6

_This also works with IPv6_

```console
npm run webpack-dev-server -- --open --port 5000 --host ::
npm run webpack-dev-server -- --open-target --port 5000 --host ::
```

## local-ip

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.

```console
npm run webpack-dev-server -- --open --port 5000 --host local-ip
npm run webpack-dev-server -- --open-target --port 5000 --host local-ip
```

## local-ipv4

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

```console
npm run webpack-dev-server -- --open --port 5000 --host local-ipv4
npm run webpack-dev-server -- --open-target --port 5000 --host local-ipv4
```

## local-ipv6

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

```console
npm run webpack-dev-server -- --open --port 5000 --host local-ipv6
npm run webpack-dev-server -- --open-target --port 5000 --host local-ipv6
```

## What Should Happen
Expand Down
30 changes: 30 additions & 0 deletions examples/cli/https/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# CLI: https

You may choose to wish to run `webpack-dev-server` on `https`.

## https

Use HTTPS protocol.

```console
npx webpack serve --open-target --https
```

## https options

Customize `https` configuration with the following options:

- `--https-key`: Path to an SSL key.
- `--https-pfx`: Path to an SSL pfx file.
- `--https-cert`: Path to an SSL certificate.
- `--https-cacert`: Path to an SSL CA certificate.
- `--https-passphrase`: Passphrase for a pfx file.

```console
npx webpack serve --open-target --https-key ./ssl/server.key --https-pfx ./ssl/server.pfx --https-cert ./ssl/server.crt --https-cacert ./ssl/ca.pem --https-passphrase webpack-dev-server
```

## What Should Happen

1. The script should open `https://localhost:8080/` in your default browser.
2. You should see the text on the page itself change to read `Success!`.
6 changes: 6 additions & 0 deletions examples/cli/https/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

const target = document.querySelector('#target');

target.classList.add('pass');
target.innerHTML = 'Success!';
27 changes: 27 additions & 0 deletions examples/cli/https/ssl/ca.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kv
C/hf5Ei1J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYu
Dy9WkFuMie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhs
EENnH6sUE9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2sw
duxJTWRINmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+
T8emgklStASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABAoIBAGqWKPE1QnT3T+3J
G+ITz9P0dDFbvWltlTZmeSJh/s2q+WZloUNtBxdmwbqT/1QecnkyGgyzVCjvSKsu
CgVjWNVAhysgtNtxRT4BVflffBXLVH2qsBjpsLRGU6EcMXuPGTiEp3YRHNuO6Aj8
oP8fEsCGPc9DlJMGgxQRAKlrVF8TN/0j6Qk+YpS4MZ0YFQfBY+WdKu04Z8TVTplQ
tTkiGpBI+Oj85jF59aQiizglJgADkAZ6zmbrctm/G9jPxh7JLS2cKI0ECZgK5yAc
pk10E1YWhoCksjr9arxy6fS9TiX9P15vv06k+s7c4c5X7XDm3X0GWeSbqBMJb8q7
BhZQNzECgYEA4kAtymDBvFYiZFq7+lzQBRKAI1RCq7YqxlieumH0PSkie2bba3dW
NVdTi7at8+GDB9/cHUPKzg/skfJllek57MZmusiVwB/Lmp/IlW8YyGShdYZ7zQsV
KMWJljpky3BEDM5sb08wIkfrOkelI/S4Bqqabd9JzOMJzoTiVOlMam8CgYEA3ctN
yonWz2bsnCUstQvQCLdI5a8Q7GJvlH2awephxGXIKGUuRmyyop0AnRnIBEWtOQV7
yZjW32bU+Wt+2BJ247EyJiIQ4gT+T51t+v/Wt1YNbL3dSj9ttOvwYd4H2W4E7EIO
GKIF4I39FM7r8NfG7YE7S1aVcnrqs01N3nhd9HMCgYEAjepbzpmqbAxLPk97oase
AFB+d6qetz5ozklAJwDSRprKukTmVR5hwMup5/UKX/OQURwl4WVojKCIb3NwLPxC
DTbVsUuoQv6uo6qeEr3A+dHFRQa6GP9eolhl2Ql/t+wPg0jn01oEgzxBXCkceNVD
qUrR2yE4FYBD4nqPzVsZR5kCgYEA1yTi7NkQeldIpZ6Z43T18753A/Xx4JsLyWqd
uAT3mV9x7V1Yqg++qGbLtZjQoPRFt85N6ZxMsqA5b0iK3mXq1auJDdx1rAlT9z6q
9JM/YNAkbZsvEVq9vIYxw31w98T1GYhpzBM+yDhzir+9tv5YhQKa1dXDWi1JhWwz
YN45pWkCgYEAxuVsJ4D4Th5o050ppWpnxM/WuMhIUKqaoFTVucMKFzn+g24y9pv5
miYdNYIk4Y+4pzHG6ZGZSHJcQ9BLui6H/nLQnqkgCb2lT5nfp7/GKdus7BdcjPGs
fcV46yL7/X0m8nDb3hkwwrDTU4mKFkMrzKpjdZBsttEmW0Aw/3y36gU=
-----END RSA PRIVATE KEY-----
21 changes: 21 additions & 0 deletions examples/cli/https/ssl/server.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJALz8gD/gAt0OMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQwHhcNMTgxMDIzMTgyMTQ5WhcNMTkxMDIzMTgyMTQ5WjBF
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAxAUVLFM+K3XDLQkBi7xt0s1Ip7JoHYDskzUDQNHjjMkUq5kvC/hf5Ei1
J6qruJs3Xqg86Nl4+ed4ynUajAkRRibhp0P1SG1tgPssIK6iC7g8heYuDy9WkFuM
ie0513zjSn6bMEAK5TegxYAWCbaCZX/Fw9bDniabL/zuOv4sf8J4EPhsEENnH6sU
E9HxPUgQmNt1Tbd0j1Cd5PXrSTLyfVPRh0m9QhXTUHuxsse8XSn9U2swduxJTWRI
NmhffYn+O7kbJGI77xYr8u58Rsf3HCMI8DTKZNvQLChvvtLJ9ckyu7Q+T8emgklS
tASm3V2UtnriaK/IQEhgSdxqVRib3QIDAQABo1AwTjAdBgNVHQ4EFgQUDZBhVKdb
3BRhLIhuuE522Vsul0IwHwYDVR0jBBgwFoAUDZBhVKdb3BRhLIhuuE522Vsul0Iw
DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEABh9WWZwWLgb9/DcTxL72
6pI96t4jiF79Q+pPefkaIIi0mE6yodWrTAsBQu9I6bNRaEcCSoiXkP2bqskD/UGg
LwUFgSrDOAA3UjdHw3QU5g2NocduG7mcFwA40TB98sOsxsUyYlzSyWzoiQWwPYwb
hek1djuWkqPXsTjlj54PTPN/SjTFmo4p5Ip6nbRf2nOREl7v0rJpGbJvXiCMYyd+
Zv+j4mRjCGo8ysMR2HjCUGkYReLAgKyyz3M7i8vevJhKslyOmy6Txn4F0nPVumaU
DDIy4xXPW1STWfsmSYJfYW3wa0wk+pJQ3j2cTzkPQQ8gwpvM3U9DJl43uwb37v6I
7Q==
-----END CERTIFICATE-----
28 changes: 28 additions & 0 deletions examples/cli/https/ssl/server.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoI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wKBgQCN6lvOmapsDEs+T3uhqx4AUH53qp63PmjOSUAnANJGmsq6ROZV
HmHAy6nn9Qpf85BRHCXhZWiMoIhvc3As/EINNtWxS6hC/q6jqp4SvcD50cVFBroY
/16iWGXZCX+37A+DSOfTWgSDPEFcKRx41UOpStHbITgVgEPieo/NWxlHmQKBgQDX
JOLs2RB6V0ilnpnjdPXzvncD9fHgmwvJap24BPeZX3HtXViqD76oZsu1mNCg9EW3
zk3pnEyyoDlvSIreZerVq4kN3HWsCVP3Pqr0kz9g0CRtmy8RWr28hjHDfXD3xPUZ
iGnMEz7IOHOKv722/liFAprV1cNaLUmFbDNg3jmlaQKBgQDG5WwngPhOHmjTnSml
amfEz9a4yEhQqpqgVNW5wwoXOf6DbjL2m/maJh01giThj7inMcbpkZlIclxD0Eu6
Lof+ctCeqSAJvaVPmd+nv8Yp26zsF1yM8ax9xXjrIvv9fSbycNveGTDCsNNTiYoW
QyvMqmN1kGy20SZbQDD/fLfqBQ==
-----END PRIVATE KEY-----
Binary file added examples/cli/https/ssl/server.pfx
Binary file not shown.
10 changes: 10 additions & 0 deletions examples/cli/https/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

// our setup function adds behind-the-scenes bits to the config that all of our
// examples need
const { setup } = require('../../util');

module.exports = setup({
context: __dirname,
entry: './app.js',
});
2 changes: 1 addition & 1 deletion examples/cli/multi-compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
`webpack-dev-server` should be able to compile multiple webpack configs.

```shell
npm run webpack-dev-server -- --open
npm run webpack-dev-server -- --open-target
```

## What Should Happen
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/node-false/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CLI: Webpack `node` Option

```shell
npm run webpack-dev-server -- --open
npm run webpack-dev-server -- --open-target
```

## What should happen
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/overlay/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CLI: --client-overlay option

```shell
npm run webpack-dev-server -- --open --client-overlay
npm run webpack-dev-server -- --open-target --client-overlay
```

## What Should Happen
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/progress/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CLI: Progress Option

```shell
npm run webpack-dev-server -- --open --client-progress
npm run webpack-dev-server -- --open-target --client-progress
```

## What Should Happen
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/public/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# CLI: Public Option

```console
npm run webpack-dev-server -- --open --host 0.0.0.0 --public <insert local ip>:8080
npm run webpack-dev-server -- --open-target --host 0.0.0.0 --public <insert local ip>:8080
```

_NOTE: replace `<insert local ip>` with your local IP Address._
Expand Down
6 changes: 3 additions & 3 deletions examples/cli/watch-static/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Watching a single directory

```console
npm run webpack-dev-server -- --static assets --open
npm run webpack-dev-server -- --static assets --open-target
```

### What Should Happen
Expand All @@ -26,13 +26,13 @@ module.exports = {
```

```console
npm run webpack-dev-server -- --open
npm run webpack-dev-server -- --open-target
```

or via CLI only:

```console
npm run webpack-dev-server -- --static assets --static css --open
npm run webpack-dev-server -- --static assets --static css --open-target
```

### What Should Happen
Expand Down