Skip to content

Commit 450b4a6

Browse files
shellscapeskipjack
authored andcommitted
docs(config): add before/after hook info to dev-server (#1608)
1 parent 6b8a165 commit 450b4a6

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/content/configuration/dev-server.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ W> Be aware that when [exporting multiple configurations](/configuration/configu
4646

4747
T> If you're having trouble, navigating to the `/webpack-dev-server` route will show where files are served. For example, `http://localhost:9000/webpack-dev-server`.
4848

49+
## `devServer.after`
50+
51+
`function`
52+
53+
Provides the ability to execute custom middleware after all other middleware
54+
internally within the server.
55+
56+
```js
57+
after(app){
58+
// do fancy stuff
59+
}
60+
```
4961

5062
## `devServer.allowedHosts`
5163

@@ -80,6 +92,21 @@ To use this option with the CLI pass the `--allowed-hosts` option a comma-delimi
8092
webpack-dev-server --entry /entry/file --output-path /output/path --allowed-hosts .host.com,host2.com
8193
```
8294

95+
## `devServer.before`
96+
97+
`function`
98+
99+
Provides the ability to execute custom middleware prior to all other middleware
100+
internally within the server. This could be used to define custom handlers, for
101+
example:
102+
103+
```js
104+
before(app){
105+
app.get('/some/path', function(req, res) {
106+
res.json({ custom: 'response' });
107+
});
108+
}
109+
```
83110

84111
## `devServer.bonjour`
85112

@@ -666,6 +693,8 @@ webpack-dev-server --quiet
666693

667694
`function`
668695

696+
W> This option is __deprecated__ in favor of `before` and will be removed in v3.0.0.
697+
669698
Here you can access the Express app object and add your own custom middleware to it.
670699
For example, to define custom handlers for some paths:
671700

0 commit comments

Comments
 (0)