const webpack = require('webpack');
const koaMiddleware = require('koa-webpack');

const cwd = process.cwd();

let config = require(`${cwd}/webpack.config`);

// Configure Hot Reload
config = require(`${cwd}/webpack/plugins/hotReload`)(config);
config = require(`${cwd}/webpack/plugins/html`)(config);

// Configure Webpack
config.output.filename = config.output.filename.replace('chunkhash', 'hash');

// Webpack compilation
const compiler = webpack(config);

// Configure Koa middleware
const devConfig = require('../configs/devServer')(config);
const hotConfig = require('../configs/hotServer')(config);

module.exports = koaMiddleware({
  compiler: compiler,
  dev: devConfig,
  hot: hotConfig,
});

@@ -75,17 +75,16 @@
 pack');%0A
-%0A
 const cw
@@ -107,18 +107,44 @@
 );%0A%0A
-le
+// Configure Hot Reload%0Acons
 t config
  = r
@@ -143,78 +143,113 @@
 nfig
+s
  = 
-require(%60$%7Bcwd%7D/webpack.config%60);%0A%0A// Configure Hot Reload%0Aconfig
+%5B%0A  'plugins/html',%0A  'plugins/hotReload',%0A%5D;%0A%0Aconst config = configs.reduce(%0A  (config, filepath)
  =
+%3E
  req
@@ -273,45 +273,32 @@
 ack/
-plugins/hotReload%60)(config);%0Aconfig =
+$%7Bfilepath%7D%60)(config),%0A 
  req
@@ -321,30 +321,18 @@
 pack
-/plugins/html%60)(
+.
 config
+%60)%0A
 );%0A%0A

Improve Koa2 middleware configuration