You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ambar2/FrontEnd/server/middleware/webpack-hmr.js

19 lines
549 B
JavaScript

import WebpackHotMiddleware from 'webpack-hot-middleware'
import applyExpressMiddleware from '../lib/apply-express-middleware'
import _debug from 'debug'
const debug = _debug('app:server:webpack-hmr')
export default function (compiler, opts) {
debug('Enable Webpack Hot Module Replacement (HMR).')
const middleware = WebpackHotMiddleware(compiler, opts)
return async function koaWebpackHMR (ctx, next) {
let hasNext = await applyExpressMiddleware(middleware, ctx.req, ctx.res)
if (hasNext && next) {
await next()
}
}
}