-
-
Save rxw1/1a34f81515a6c89d2a1b to your computer and use it in GitHub Desktop.
koa-webpack-middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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