Skip to content

Commit

Permalink
chore: migrate script for examples on setupMiddlewares option (#4347)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Mar 18, 2022
1 parent a7ccab1 commit 84b4774
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions examples/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,17 @@ module.exports = {
})
);

if (result.devServer.onBeforeSetupMiddleware) {
const proxy = result.devServer.onBeforeSetupMiddleware;
result.devServer.onBeforeSetupMiddleware = function replace(app) {
onBeforeSetupMiddleware(app);
proxy(app);
if (result.devServer.setupMiddlewares) {
const proxy = result.devServer.setupMiddlewares;
result.devServer.setupMiddlewares = (middlewares, devServer) => {
onBeforeSetupMiddleware(devServer);
return proxy(middlewares, devServer);
};
} else {
result.devServer.onBeforeSetupMiddleware = onBeforeSetupMiddleware;
result.devServer.setupMiddlewares = (middlewares, devServer) => {
onBeforeSetupMiddleware(devServer);
return middlewares;
};
}

const output = {
Expand Down

0 comments on commit 84b4774

Please sign in to comment.