Skip to content

Commit 7a02ba2

Browse files
committed
fix(server): 修复 win 下 publicpath 替换问题
1 parent f4f0fb3 commit 7a02ba2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/commands/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,12 @@ exports.run = function (options) {
208208
var localPublicPath = wpConfig.output.local.publicPath;
209209
var hostReg = /(http:|https:)?(\/\/)([^\/]+)/i;
210210
if (localPublicPath && localPublicPath.match(hostReg).length === 4) {
211+
localPublicPath = '/' + UtilPath.normalize(localPublicPath, false);
211212
localPublicPath = localPublicPath.replace(hostReg, function (matches, httpStr, splitStr, host) {
212213
httpStr = httpStr || '';
213-
return httpStr + splitStr + UtilPath.normalize(['127.0.0.1:' + port].join(''), false);
214+
return httpStr + '//' + '127.0.0.1:' + port;
214215
});
216+
215217
wpConfig.output.local.publicPath = localPublicPath;
216218
} else {
217219
// hot 且 未指定 publicPath 需要手动设置方式 hot.json 404

src/commands/server.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,12 @@ exports.run = (options) => {
204204
let localPublicPath = wpConfig.output.local.publicPath;
205205
const hostReg = /(http:|https:)?(\/\/)([^\/]+)/i;
206206
if(localPublicPath && localPublicPath.match(hostReg).length === 4) {
207+
localPublicPath = '/' + UtilPath.normalize(localPublicPath, false);
207208
localPublicPath = localPublicPath.replace(hostReg, (matches, httpStr, splitStr, host) => {
208209
httpStr = httpStr || '';
209-
return httpStr + splitStr + UtilPath.normalize(['127.0.0.1:' + port].join(''), false);
210+
return httpStr + '//' + '127.0.0.1:' + port;
210211
});
212+
211213
wpConfig.output.local.publicPath = localPublicPath;
212214
} else {
213215
// hot 且 未指定 publicPath 需要手动设置方式 hot.json 404

0 commit comments

Comments
 (0)