@@ -10,9 +10,15 @@ class ErrorOverlayPlugin {
1010 if ( compiler . options . mode !== 'development' ) return
1111
1212 const devServerEnabled = ! ! compiler . options . devServer
13+ const sockOptions = { }
14+ if ( devServerEnabled ) {
15+ sockOptions . sockHost = compiler . options . devServer . sockHost
16+ sockOptions . sockPath = compiler . options . devServer . sockPath
17+ sockOptions . sockPort = compiler . options . devServer . sockPort
18+ }
1319
1420 compiler . hooks . entryOption . tap ( className , ( context , entry ) => {
15- adjustEntry ( entry , devServerEnabled )
21+ adjustEntry ( entry , devServerEnabled , sockOptions )
1622 } )
1723
1824 compiler . hooks . afterResolvers . tap ( className , ( { options } ) => {
@@ -29,7 +35,7 @@ class ErrorOverlayPlugin {
2935 }
3036}
3137
32- function adjustEntry ( entry , enableDevServer ) {
38+ function adjustEntry ( entry , enableDevServer , sockOptions ) {
3339 if ( typeof entry === 'string' ) {
3440 throw new Error (
3541 `We currently do not inject our entry code into single-file anonymous entries.
@@ -39,8 +45,12 @@ Please use a multi-main (array) or object-form \`entry\` setting for now.`,
3945
4046 if ( Array . isArray ( entry ) ) {
4147 if ( enableDevServer ) {
42- if ( ! entry . includes ( chunkPathDevServer ) ) {
43- entry . unshift ( chunkPathDevServer )
48+ const sockHost = sockOptions . sockHost ? `&sockHost=${ sockOptions . sockHost } ` : ''
49+ const sockPath = sockOptions . sockPath ? `&sockPath=${ sockOptions . sockPath } ` : ''
50+ const sockPort = sockOptions . sockPort ? `&sockPort=${ sockOptions . sockPort } ` : ''
51+ const chunkPathDevServerWithParams = `${ chunkPathDevServer } ?${ sockHost } ${ sockPath } ${ sockPort } `
52+ if ( ! entry . includes ( chunkPathDevServerWithParams ) ) {
53+ entry . unshift ( chunkPathDevServerWithParams )
4454 }
4555 }
4656
@@ -49,7 +59,7 @@ Please use a multi-main (array) or object-form \`entry\` setting for now.`,
4959 }
5060 } else {
5161 Object . keys ( entry ) . forEach ( entryName => {
52- entry [ entryName ] = adjustEntry ( entry [ entryName ] , enableDevServer )
62+ entry [ entryName ] = adjustEntry ( entry [ entryName ] , enableDevServer , sockOptions )
5363 } )
5464 }
5565
0 commit comments