Skip to content

Commit

Permalink
feat: deprecate setup in favor of before and after hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnbroder committed Sep 20, 2017
1 parent 3e24ac4 commit a1aa891
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/Server.js
Expand Up @@ -323,7 +323,9 @@ function Server(compiler, options) {

middleware: () => {
// include our middleware to ensure it is able to handle '/index.html' request after redirect
if (typeof options.before === 'function') { options.before(app, this); }
app.use(this.middleware);
if (typeof options.after === 'function') { options.after(app, this); }
},

headers: () => {
Expand All @@ -335,6 +337,8 @@ function Server(compiler, options) {
},

setup: () => {
log('Using "setup" is deprecated and will be removed in the next major version. Please use the "before" and "after" hooks instead.');
log('If "setup" was working fine for you until now, simply replace it with "before"');
if (typeof options.setup === 'function') { options.setup(app, this); }
}
};
Expand Down
8 changes: 8 additions & 0 deletions lib/optionsSchema.json
Expand Up @@ -274,6 +274,14 @@
"description": "Exposes the Express server to add custom middleware or routes.",
"instanceof": "Function"
},
"before": {
"description": "Exposes the Express server to add custom middleware or routes before webpack-dev-middleware will be added.",
"instanceof": "Function"
},
"after": {
"description": "Exposes the Express server to add custom middleware or routes after webpack-dev-middleware got added.",
"instanceof": "Function"
},
"stats": {
"description": "Decides what bundle information is displayed.",
"anyOf": [
Expand Down
2 changes: 1 addition & 1 deletion test/Validation.test.js
Expand Up @@ -51,7 +51,7 @@ describe('Validation', () => {
' object { hot?, hotOnly?, lazy?, bonjour?, host?, allowedHosts?, filename?, publicPath?, port?, socket?, ' +
'watchOptions?, headers?, clientLogLevel?, overlay?, progress?, key?, cert?, ca?, pfx?, pfxPassphrase?, requestCert?, ' +
'inline?, disableHostCheck?, public?, https?, contentBase?, watchContentBase?, open?, useLocalIp?, openPage?, features?, ' +
'compress?, proxy?, historyApiFallback?, staticOptions?, setup?, stats?, reporter?, ' +
'compress?, proxy?, historyApiFallback?, staticOptions?, setup?, before?, after? stats?, reporter?, ' +
'noInfo?, quiet?, serverSideRender?, index?, log?, warn? }'
]
}];
Expand Down

0 comments on commit a1aa891

Please sign in to comment.