File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -246,7 +246,8 @@ exports.run = function (options) {
246
246
}
247
247
248
248
// hot reload
249
- if ( hot ) {
249
+ var hotEnabled = project . server && project . server . hot || hot ;
250
+ if ( hotEnabled ) {
250
251
// 修改 publicPath 为当前服务
251
252
var localPublicPath = wpConfig . output . local . publicPath ;
252
253
if ( project . config . replacingPublicPath !== false ) {
@@ -261,7 +262,7 @@ exports.run = function (options) {
261
262
} else {
262
263
// hot 且 未指定 publicPath 需要手动设置方式 hot.json 404
263
264
var relativePath = sysPath . relative ( projectCwd , wpConfig . output . local . path ) ;
264
- wpConfig . output . local . publicPath = '/' + projectName + '/' + relativePath + '/' ;
265
+ wpConfig . output . local . publicPath = 'http://127.0.0.1:' + port + ' /' + projectName + '/' + relativePath + '/' ;
265
266
}
266
267
}
267
268
@@ -274,7 +275,8 @@ exports.run = function (options) {
274
275
var entryItem = wpConfig . entry [ key ] ;
275
276
if ( sysPath . extname ( entryItem [ entryItem . length - 1 ] ) === '.js' ) {
276
277
var whmPath = require . resolve ( 'webpack-hot-middleware/client' ) ;
277
- entryItem . unshift ( whmPath + '?reload=true&path=/__webpack_hmr&timeout=9999999' ) ;
278
+ var hotPath = 'http://127.0.0.1:' + port + '/__webpack_hmr' ;
279
+ entryItem . unshift ( whmPath + '?reload=true&path=' + hotPath + '&timeout=9999999&overlay=false' ) ;
278
280
}
279
281
return entryItem ;
280
282
} ) ;
@@ -450,11 +452,12 @@ exports.run = function (options) {
450
452
}
451
453
} ) ;
452
454
453
- if ( hot ) {
455
+ if ( hotEnabled ) {
454
456
app . use ( require ( 'webpack-hot-middleware' ) ( compiler , {
455
457
log : false ,
456
458
path : '/__webpack_hmr'
457
459
} ) ) ;
460
+
458
461
logInfo ( 'Start hot reloader server.' ) ;
459
462
}
460
463
Original file line number Diff line number Diff line change @@ -242,7 +242,8 @@ exports.run = (options) => {
242
242
}
243
243
244
244
// hot reload
245
- if ( hot ) {
245
+ const hotEnabled = ( project . server && project . server . hot ) || hot ;
246
+ if ( hotEnabled ) {
246
247
// 修改 publicPath 为当前服务
247
248
let localPublicPath = wpConfig . output . local . publicPath ;
248
249
if ( project . config . replacingPublicPath !== false ) {
@@ -257,7 +258,7 @@ exports.run = (options) => {
257
258
} else {
258
259
// hot 且 未指定 publicPath 需要手动设置方式 hot.json 404
259
260
const relativePath = sysPath . relative ( projectCwd , wpConfig . output . local . path ) ;
260
- wpConfig . output . local . publicPath = `/${ projectName } /${ relativePath } /` ;
261
+ wpConfig . output . local . publicPath = `http://127.0.0.1: ${ port } /${ projectName } /${ relativePath } /` ;
261
262
}
262
263
}
263
264
@@ -270,7 +271,8 @@ exports.run = (options) => {
270
271
let entryItem = wpConfig . entry [ key ] ;
271
272
if ( sysPath . extname ( entryItem [ entryItem . length - 1 ] ) === '.js' ) {
272
273
const whmPath = require . resolve ( 'webpack-hot-middleware/client' ) ;
273
- entryItem . unshift ( whmPath + '?reload=true&path=/__webpack_hmr&timeout=9999999' ) ;
274
+ const hotPath = `http://127.0.0.1:${ port } /__webpack_hmr` ;
275
+ entryItem . unshift ( whmPath + '?reload=true&path=' + hotPath + '&timeout=9999999&overlay=false' ) ;
274
276
}
275
277
return entryItem ;
276
278
} ) ;
@@ -450,11 +452,12 @@ exports.run = (options) => {
450
452
}
451
453
) ;
452
454
453
- if ( hot ) {
455
+ if ( hotEnabled ) {
454
456
app . use ( require ( 'webpack-hot-middleware' ) ( compiler , {
455
457
log : false ,
456
458
path : '/__webpack_hmr'
457
459
} ) ) ;
460
+
458
461
logInfo ( 'Start hot reloader server.' ) ;
459
462
}
460
463
You can’t perform that action at this time.
0 commit comments