@@ -64,7 +64,7 @@ T> HTML template is required to serve the bundle, usually it is an `index.html`
6464
6565## ` devServer.after `
6666
67- ` function (app, server) `
67+ ` function (app, server, compiler ) `
6868
6969Provides the ability to execute custom middleware after all other middleware
7070internally within the server.
@@ -75,7 +75,7 @@ __webpack.config.js__
7575module .exports = {
7676 // ...
7777 devServer: {
78- after : function (app , server ) {
78+ after : function (app , server , compiler ) {
7979 // do fancy stuff
8080 }
8181 }
@@ -131,7 +131,7 @@ webpack-dev-server --entry /entry/file --output-path /output/path --allowed-host
131131
132132## ` devServer.before `
133133
134- ` function (app, server) `
134+ ` function (app, server, compiler ) `
135135
136136Provides the ability to execute custom middleware prior to all other middleware
137137internally within the server. This could be used to define custom handlers, for
@@ -143,7 +143,7 @@ __webpack.config.js__
143143module .exports = {
144144 // ...
145145 devServer: {
146- before : function (app , server ) {
146+ before : function (app , server , compiler ) {
147147 app .get (' /some/path' , function (req , res ) {
148148 res .json ({ custom: ' response' });
149149 });
@@ -763,6 +763,25 @@ module.exports = {
763763};
764764```
765765
766+ ## ` devServer.onListening `
767+
768+ ` function (server) `
769+
770+ Provides an option to execute a custom function when ` webpack-dev-server ` starts listening for connections on a port.
771+
772+ __ webpack.config.js__
773+
774+ ``` javascript
775+ module .exports = {
776+ // ...
777+ devServer: {
778+ onListening : function (server ) {
779+ const port = server .listeningApp .address ().port ;
780+ console .log (' Listening on port:' , port);
781+ }
782+ }
783+ };
784+ ```
766785
767786## ` devServer.open `
768787
0 commit comments