octatone / koa-webpack-hot-middleware

47 stars 9 forks source link

app.use() requires a generator function #2

Open JoeGrasso opened 9 years ago

JoeGrasso commented 9 years ago

I have the following code:

var path = require('path'); var koa = require('koa'); var app = module.exports = koa(); var webpack = require('webpack'); var webpackConfig = require('../webpack/webpack.config.dev'); var compiler = webpack(webpackConfig);

app.use(require("webpack-dev-middleware")(compiler, { noInfo: true, publicPath: webpackConfig.output.publicPath }));

app.use(require('webpack-hot-middleware')(compiler));

app.get('*', function(req, res) { res.sendFile(path.join(__dirname, 'index.html')); });

app.listen(3000, 'localhost', function(err) { if (err) { console.log(err); return; }

console.log('Listening at http://localhost:3000'); });

The error is on the "app.use(require("webpack-dev-middleware")(compiler ..."

Any help please.

tomatau commented 9 years ago

The docs weren't updated to reflect usage.

      app.use(require('koa-webpack-dev-middleware')(compiler, {
        quiet: true,
        noInfo: true,
        stats: {
          colors: true,
          reasons: true,
        },
        // etc..
      }))
      app.use(require('koa-webpack-hot-middleware')(compiler));