Skip to content

Commit 2560fce

Browse files
authored
docs(configuration): add devserver.onListening (#5304)
1 parent 702390a commit 2560fce

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/content/configuration/dev-server.mdx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,26 @@ module.exports = {
829829
};
830830
```
831831

832+
## devserver.onListening
833+
834+
`function (server)`
835+
836+
Provides the ability to execute a custom function when webpack-dev-server starts listening for connections on a port.
837+
838+
**webpack.config.js**
839+
840+
```javascript
841+
module.exports = {
842+
//...
843+
devServer: {
844+
onListening: function (server) {
845+
const port = server.address().port;
846+
console.log('Listening on port:', port);
847+
},
848+
},
849+
};
850+
```
851+
832852
## devServer.open
833853

834854
`boolean` `string` `[string]` `object` `[object]`

0 commit comments

Comments
 (0)