Provides the ability to execute custom middleware after all other middleware internally within the server.
webpack.config.js
module.exports = {
// ...
devServer: {
onAfterSetupMiddleware: (devServer) => {
devServer.app.get("/after/some/path", (_, response) => {
response.send("after");
});
},
},
};
To run this example use the following command:
npx webpack serve --open
- The script should open
http://localhost:8080/
in your default browser. - You should see the text on the page itself change to read
Success!
. - Go to
http://localhost:8080/after/some/path
, you should see the text on the page itself change to readafter
.