Skip to content
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

docs(configuration): add onListening, update after and before in devServer #3317

Merged
merged 3 commits into from
Oct 28, 2019
Merged
Changes from 2 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
27 changes: 23 additions & 4 deletions src/content/configuration/dev-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ T> HTML template is required to serve the bundle, usually it is an `index.html`

## `devServer.after`

`function (app, server)`
`function (app, server, compiler)`

Provides the ability to execute custom middleware after all other middleware
internally within the server.
Expand All @@ -74,7 +74,7 @@ __webpack.config.js__
module.exports = {
//...
devServer: {
after: function(app, server) {
after: function(app, server, compiler) {
// do fancy stuff
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ webpack-dev-server --entry /entry/file --output-path /output/path --allowed-host

## `devServer.before`

`function (app, server)`
`function (app, server, compiler)`

Provides the ability to execute custom middleware prior to all other middleware
internally within the server. This could be used to define custom handlers, for
Expand All @@ -142,7 +142,7 @@ __webpack.config.js__
module.exports = {
//...
devServer: {
before: function(app, server) {
before: function(app, server, compiler) {
app.get('/some/path', function(req, res) {
res.json({ custom: 'response' });
});
Expand Down Expand Up @@ -762,6 +762,25 @@ module.exports = {
};
```

## `devServer.onListening`

`function (server)`

Provides an option to execute a custom function when `webpack-dev-server` starts listening for connections on a port.

__webpack.config.js__

```javascript
module.exports = {
//...
devServer: {
onListening: function(server) {
const port = server.listeningApp.address().port;
console.log('Listening on port:', port);
}
}
};
```

## `devServer.open`

Expand Down