webpack/webpack-dev-server — pull request #89 by manpages (2014-12-22 05:42:28+00:00)
Title: Add configurable express initializer for mocking

It's no secret that oftentimes when frontend teams work with
webpack, the backend they see and the real backend are different
things. Also, it's known that often such "mocking" backend is
implemented with Express.

This small patch provides a way to adapt a mocking backend to
webpack-dev-server with a simple adapter. It also allows us to
make template engines play better with webpack-dev-server.

===

Invocation example:

```
WDSMOCK='/tmp/wdsmock.js' node bin/webpack-dev-server.js
```

(should go into a script in your package.json);

Initializer example:

```
module.exports.mock = function(app) {

app.get('/mocked', function(req, res) {
res.setHeader("Content-Type", "text/html");
res.write('' +
'Mocked!' +
'');
res.send();
})

app.get('/mocked/:param', function(req, res) {
res.setHeader("Content-Type", "text/html");
res.write('' +
'' + req.params.param + '!' +
'');
res.send();
})

return app;

}
```