'use strict'


const devMiddleware = require('webpack-dev-middleware')

module.exports = (compiler, opts) => {
  const expressMiddleware = devMiddleware(compiler, opts)
  function a(ctx, next) {
    return expressMiddleware(ctx.req, {
      end: (content) => {
        ctx.body = content
      },
      setHeader: (name, value) => {
        ctx.headers[name] = value
      }
    },next)
    
    // return next();
  }
  a.fileSystem = expressMiddleware.fileSystem
  return a;
}
'use strict'


const devMiddleware = require('webpack-dev-middleware')

module.exports = (compiler, opts) => {
  const expressMiddleware = devMiddleware(compiler, opts)
  let nextFlag = false;
  function nextFn() {
    nextFlag = true;
  }
  function devFn(ctx, next) {
    expressMiddleware(ctx.req, {
        end: (content) => {
          ctx.body = content
        },
        setHeader: (name, value) => {
          ctx.headers[name] = value
        }
      }, nextFn)
    if(nextFlag) {
      nextFlag = false;
      return next();
    }
  }
  devFn.fileSystem = expressMiddleware.fileSystem
  return devFn;
}

修复koa封装webpack-dev-middleware的next会产生bug的问题