Skip to content

Instantly share code, notes, and snippets.

@cahnory
Created December 21, 2015 15:55
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 cahnory/3deaa1153dc98adfd7e2 to your computer and use it in GitHub Desktop.
Save cahnory/3deaa1153dc98adfd7e2 to your computer and use it in GitHub Desktop.
koa-webpack-middleware
import connect from 'koa-connect';
import compose from 'koa-compose';
import webpack from 'webpack';
import webpackDev from 'webpack-dev-middleware';
import webpackHot from 'webpack-hot-middleware';
export default function (config = {}) {
let compiler = webpack(config);
return compose([
// quick fix
function * (next) {
this.status = 200;
yield next;
},
connect(webpackDev(compiler, {
noInfo: true,
publicPath: config.output.publicPath
})),
connect(webpackHot(compiler))
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment