Skip to content

Commit

Permalink
docs: improve http2 example (#3832)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Sep 11, 2021
1 parent 2b1208d commit f812e01
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 23 deletions.
25 changes: 25 additions & 0 deletions examples/http2/boolean/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# http2 option

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.

## HTTP/2 with a self-signed certificate:

```js
module.exports = {
// ...
devServer: {
http2: true,
},
};
```

Usage via CLI:

```console
npx webpack serve --open --http2
```

### 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!`.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

module.exports = setup({
context: __dirname,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,6 @@

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.

## HTTP/2 with a self-signed certificate:

```js
module.exports = {
// ...
devServer: {
http2: true,
},
};
```

Usage via CLI:

```console
npx webpack serve --open --http2
```

### 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!`.

## HTTP/2 with a custom certificate:

Provide your own certificate using the [https](https://webpack.js.org/configuration/dev-server/#devserverhttps) option:
Expand Down
6 changes: 6 additions & 0 deletions examples/http2/with-https-configuration/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!";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions examples/http2/with-https-configuration/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"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",
devServer: {
http2: true,
https: {
key: "./ssl/server.key",
pfx: "./ssl/server.pfx",
cert: "./ssl/server.crt",
ca: "./ssl/ca.pem",
passphrase: "webpack-dev-server",
},
},
});

0 comments on commit f812e01

Please sign in to comment.