const express = require('express'); const webpack = require('webpack'); const middleware = require('webpack-dev-middleware'); const proxy = require('koa-better-http-proxy'); const url = require('url'); const devConfig = require('../webpack.config'); const compiler = webpack(devConfig); module.exports = { entry(app, router, opts) { app.use(proxy('http://localhost:5001', { filter(ctx) { return /\/build/.test(url.parse(ctx.url).path); }, proxyReqPathResolver(ctx) { return `client${url.parse(ctx.url).path}`; }, })); app.use(proxy('http://localhost:5001', { filter(ctx) { return /\/$/.test(url.parse(ctx.url).path); }, proxyReqPathResolver(ctx) { return 'client/build/index.html'; }, })); const server = express(); server.use(middleware(compiler)); // server.use(require("webpack-hot-middleware")(compiler)); server.listen('5001', (err) => { if (err) { console.log(err); } }); }, };