@@ -64,7 +64,7 @@ T> HTML template is required to serve the bundle, usually it is an `index.html`
64
64
65
65
## ` devServer.after `
66
66
67
- ` function (app, server) `
67
+ ` function (app, server, compiler ) `
68
68
69
69
Provides the ability to execute custom middleware after all other middleware
70
70
internally within the server.
@@ -75,7 +75,7 @@ __webpack.config.js__
75
75
module .exports = {
76
76
// ...
77
77
devServer: {
78
- after : function (app , server ) {
78
+ after : function (app , server , compiler ) {
79
79
// do fancy stuff
80
80
}
81
81
}
@@ -131,7 +131,7 @@ webpack-dev-server --entry /entry/file --output-path /output/path --allowed-host
131
131
132
132
## ` devServer.before `
133
133
134
- ` function (app, server) `
134
+ ` function (app, server, compiler ) `
135
135
136
136
Provides the ability to execute custom middleware prior to all other middleware
137
137
internally within the server. This could be used to define custom handlers, for
@@ -143,7 +143,7 @@ __webpack.config.js__
143
143
module .exports = {
144
144
// ...
145
145
devServer: {
146
- before : function (app , server ) {
146
+ before : function (app , server , compiler ) {
147
147
app .get (' /some/path' , function (req , res ) {
148
148
res .json ({ custom: ' response' });
149
149
});
@@ -763,6 +763,25 @@ module.exports = {
763
763
};
764
764
```
765
765
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
+ ```
766
785
767
786
## ` devServer.open `
768
787
0 commit comments