From cbeb55d9a9cfe4eec8b84b5fa319512c4c410fe0 Mon Sep 17 00:00:00 2001 From: Anna Teng Date: Wed, 22 Jul 2020 18:34:04 -0400 Subject: [PATCH] fix webpack-hot-middleware reloading/navigation issue --- index.js | 5 +++-- webpack.config.js | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 62b075a..99ad350 100644 --- a/index.js +++ b/index.js @@ -34,11 +34,12 @@ if (!inProduction) { const hotMiddleWare = require('webpack-hot-middleware') const webpackConf = require('@root/webpack.config') /* eslint-enable */ - const compiler = webpack(webpackConf('development', { mode: 'development' })) + const config = webpackConf('development', { mode: 'development' }) + const compiler = webpack(config) const devMiddleware = middleware(compiler) app.use(devMiddleware) - app.use(hotMiddleWare(compiler)) + app.use(hotMiddleWare(compiler, { publicPath: config.output.publicPath })) app.use('*', (req, res, next) => { const filename = path.join(compiler.outputPath, 'index.html') devMiddleware.waitUntilValid(() => { diff --git a/webpack.config.js b/webpack.config.js index 5c679cc..a1564e1 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -72,5 +72,8 @@ module.exports = (env, argv) => { }), ...additionalPlugins, ], + output: { + publicPath: '/' + } } }