Skip to content

Instantly share code, notes, and snippets.

@kafkahw
Created January 19, 2017 20:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kafkahw/54d03cc5caf84c9383c4d355e33c67a7 to your computer and use it in GitHub Desktop.
Save kafkahw/54d03cc5caf84c9383c4d355e33c67a7 to your computer and use it in GitHub Desktop.
Mock API with webpack
https://webpack.github.io/docs/webpack-dev-server.html#api
If mocking API is needed when running webpack dev server, you can set it up in your webpack config as follows:
devServer: {
setup: function(app) {
// Here you can access the Express app object and add your own custom middleware to it.
// For example, to define custom handlers for some paths:
// app.get('/some/path', function(req, res) {
// res.json({ custom: 'response' });
// });
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment