Skip to content

Commit f812e01

Browse files
authored
docs: improve http2 example (#3832)
1 parent 2b1208d commit f812e01

File tree

10 files changed

+52
-23
lines changed

10 files changed

+52
-23
lines changed

examples/http2/boolean/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# http2 option
2+
3+
Serve over HTTP/2 using [spdy](https://www.npmjs.com/package/spdy). This option is ignored for Node 15.0.0 and above, as `spdy` is broken for those versions.
4+
5+
## HTTP/2 with a self-signed certificate:
6+
7+
```js
8+
module.exports = {
9+
// ...
10+
devServer: {
11+
http2: true,
12+
},
13+
};
14+
```
15+
16+
Usage via CLI:
17+
18+
```console
19+
npx webpack serve --open --http2
20+
```
21+
22+
### What Should Happen
23+
24+
1. The script should open `https://localhost:8080/` in your default browser.
25+
2. You should see the text on the page itself change to read `Success!`.
File renamed without changes.

examples/http2/webpack.config.js renamed to examples/http2/boolean/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// our setup function adds behind-the-scenes bits to the config that all of our
44
// examples need
5-
const { setup } = require("../util");
5+
const { setup } = require("../../util");
66

77
module.exports = setup({
88
context: __dirname,

examples/http2/README.md renamed to examples/http2/with-https-configuration/README.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,6 @@
22

33
Serve over HTTP/2 using [spdy](https://www.npmjs.com/package/spdy). This option is ignored for Node 15.0.0 and above, as `spdy` is broken for those versions.
44

5-
## HTTP/2 with a self-signed certificate:
6-
7-
```js
8-
module.exports = {
9-
// ...
10-
devServer: {
11-
http2: true,
12-
},
13-
};
14-
```
15-
16-
Usage via CLI:
17-
18-
```console
19-
npx webpack serve --open --http2
20-
```
21-
22-
### What Should Happen
23-
24-
1. The script should open `https://localhost:8080/` in your default browser.
25-
2. You should see the text on the page itself change to read `Success!`.
26-
275
## HTTP/2 with a custom certificate:
286

297
Provide your own certificate using the [https](https://webpack.js.org/configuration/dev-server/#devserverhttps) option:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
"use strict";
2+
3+
const target = document.querySelector("#target");
4+
5+
target.classList.add("pass");
6+
target.innerHTML = "Success!";
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"use strict";
2+
3+
// our setup function adds behind-the-scenes bits to the config that all of our
4+
// examples need
5+
const { setup } = require("../../util");
6+
7+
module.exports = setup({
8+
context: __dirname,
9+
entry: "./app.js",
10+
devServer: {
11+
http2: true,
12+
https: {
13+
key: "./ssl/server.key",
14+
pfx: "./ssl/server.pfx",
15+
cert: "./ssl/server.crt",
16+
ca: "./ssl/ca.pem",
17+
passphrase: "webpack-dev-server",
18+
},
19+
},
20+
});

0 commit comments

Comments
 (0)