@@ -5,8 +5,9 @@ const path = require("path");
55const open = require ( "opn" ) ;
66const fs = require ( "fs" ) ;
77const net = require ( "net" ) ;
8- const url = require ( "url" ) ;
98const portfinder = require ( "portfinder" ) ;
9+ const addDevServerEntrypoints = require ( "../lib/util/addDevServerEntrypoints" ) ;
10+ const createDomain = require ( "../lib/util/createDomain" ) ;
1011
1112// Local version replaces global one
1213try {
@@ -327,33 +328,7 @@ function processOptions(wpOpt) {
327328}
328329
329330function startDevServer ( wpOpt , options ) {
330- const protocol = options . https ? "https" : "http" ;
331-
332- // the formatted domain (url without path) of the webpack server
333- const domain = options . public ? `${ protocol } ://${ options . public } ` : url . format ( {
334- protocol : protocol ,
335- hostname : options . host ,
336- port : options . socket ? 0 : options . port . toString ( )
337- } ) ;
338-
339- if ( options . inline !== false ) {
340- const devClient = [ `${ require . resolve ( "../client/" ) } ?${ domain } ` ] ;
341-
342- if ( options . hotOnly )
343- devClient . push ( "webpack/hot/only-dev-server" ) ;
344- else if ( options . hot )
345- devClient . push ( "webpack/hot/dev-server" ) ;
346-
347- [ ] . concat ( wpOpt ) . forEach ( function ( wpOpt ) {
348- if ( typeof wpOpt . entry === "object" && ! Array . isArray ( wpOpt . entry ) ) {
349- Object . keys ( wpOpt . entry ) . forEach ( function ( key ) {
350- wpOpt . entry [ key ] = devClient . concat ( wpOpt . entry [ key ] ) ;
351- } ) ;
352- } else {
353- wpOpt . entry = devClient . concat ( wpOpt . entry ) ;
354- }
355- } ) ;
356- }
331+ addDevServerEntrypoints ( wpOpt , options ) ;
357332
358333 let compiler ;
359334 try {
@@ -372,7 +347,7 @@ function startDevServer(wpOpt, options) {
372347 } ) ) ;
373348 }
374349
375- const uri = domain + ( options . inline !== false || options . lazy === true ? "/" : "/webpack-dev-server/" ) ;
350+ const uri = createDomain ( options ) + ( options . inline !== false || options . lazy === true ? "/" : "/webpack-dev-server/" ) ;
376351
377352 let server ;
378353 try {
0 commit comments