Skip to content

Commit 5c27b5e

Browse files
knagaitsevEugeneHlushko
authored andcommitted
docs(dev-server): New http2 option (#2923)
* docs(dev-server): add `http2` option * docs(dev-server): add CLI cert usage for `http2` * docs(dev-server): handled combination case for http2/https, clarified CLI wording
1 parent 70279da commit 5c27b5e

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/content/configuration/dev-server.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ contributors:
1010
- byzyk
1111
- EugeneHlushko
1212
- Yiidiir
13+
- Loonride
1314
---
1415

1516
[webpack-dev-server](https://github.com/webpack/webpack-dev-server) can be used to quickly develop an application. See the [development guide](/guides/development/) to get started.
@@ -472,6 +473,58 @@ webpack-dev-server --hot-only
472473
```
473474

474475

476+
## `devServer.http2`
477+
478+
`boolean: false`
479+
480+
Serve over HTTP/2 using [spdy](https://www.npmjs.com/package/spdy). This option is ignored for Node 10.0.0 and above, as spdy is broken for those versions. The dev server will migrate over to Node's built-in HTTP/2 once [Express](https://expressjs.com/) supports it.
481+
482+
If `devServer.http2` is not explicitly set to `false`, it will default to `true` when [`devServer.https`](#devserverhttps) is enabled. When `devServer.http2` is enabled but the server is unable to serve over HTTP/2, the server defaults to HTTPS.
483+
484+
HTTP/2 with a self-signed certificate:
485+
486+
__webpack.config.js__
487+
488+
```javascript
489+
module.exports = {
490+
//...
491+
devServer: {
492+
http2: true
493+
}
494+
};
495+
```
496+
497+
Provide your own certificate using the [https](#devserverhttps) option:
498+
499+
__webpack.config.js__
500+
501+
```javascript
502+
module.exports = {
503+
//...
504+
devServer: {
505+
http2: true,
506+
https: {
507+
key: fs.readFileSync('/path/to/server.key'),
508+
cert: fs.readFileSync('/path/to/server.crt'),
509+
ca: fs.readFileSync('/path/to/ca.pem'),
510+
}
511+
}
512+
};
513+
```
514+
515+
Usage via CLI
516+
517+
```bash
518+
webpack-dev-server --http2
519+
```
520+
521+
To pass your own certificate via CLI, use the following options
522+
523+
```bash
524+
webpack-dev-server --http2 --key /path/to/server.key --cert /path/to/server.crt --cacert /path/to/ca.pem
525+
```
526+
527+
475528
## `devServer.https`
476529

477530
`boolean` `object`

0 commit comments

Comments
 (0)