Skip to content

Commit 9e39a0e

Browse files
committed
fix(hot): fix Express wildcard routing breaks
1 parent 12e7f53 commit 9e39a0e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/commands/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ exports.run = function (options) {
210210
// hot reload
211211
if (hot) {
212212
// 修改 publicPath 为当前服务
213+
var localPublicPath = wpConfig.output.local.publicPath;
213214
if (project.config.replacingPublicPath !== false) {
214-
var localPublicPath = wpConfig.output.local.publicPath;
215215
var hostReg = /(http:|https:)?(\/\/)([^\/]+)/i;
216216
if (localPublicPath && localPublicPath.match(hostReg).length === 4) {
217217
localPublicPath = '/' + UtilPath.normalize(localPublicPath, false);
@@ -237,7 +237,7 @@ exports.run = function (options) {
237237
var entryItem = wpConfig.entry[key];
238238
if (sysPath.extname(entryItem[entryItem.length - 1]) === '.js') {
239239
var whmPath = require.resolve('webpack-hot-middleware/client');
240-
entryItem.unshift(whmPath + '?reload=true');
240+
entryItem.unshift(whmPath + '?reload=true&path=' + localPublicPath + '__webpack_hmr');
241241
}
242242
return entryItem;
243243
});

src/commands/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ exports.run = (options) => {
206206
// hot reload
207207
if(hot) {
208208
// 修改 publicPath 为当前服务
209+
let localPublicPath = wpConfig.output.local.publicPath;
209210
if(project.config.replacingPublicPath !== false) {
210-
let localPublicPath = wpConfig.output.local.publicPath;
211211
const hostReg = /(http:|https:)?(\/\/)([^\/]+)/i;
212212
if(localPublicPath && localPublicPath.match(hostReg).length === 4) {
213213
localPublicPath = '/' + UtilPath.normalize(localPublicPath, false);
@@ -233,7 +233,7 @@ exports.run = (options) => {
233233
let entryItem = wpConfig.entry[key];
234234
if(sysPath.extname(entryItem[entryItem.length - 1]) === '.js') {
235235
const whmPath = require.resolve('webpack-hot-middleware/client');
236-
entryItem.unshift(whmPath + '?reload=true' );
236+
entryItem.unshift(whmPath + '?reload=true&path=' + localPublicPath + '__webpack_hmr' );
237237
}
238238
return entryItem;
239239
});

0 commit comments

Comments
 (0)