@@ -5,8 +5,9 @@ const path = require("path");
5
5
const open = require ( "opn" ) ;
6
6
const fs = require ( "fs" ) ;
7
7
const net = require ( "net" ) ;
8
- const url = require ( "url" ) ;
9
8
const portfinder = require ( "portfinder" ) ;
9
+ const addDevServerEntrypoints = require ( "../lib/util/addDevServerEntrypoints" ) ;
10
+ const createDomain = require ( "../lib/util/createDomain" ) ;
10
11
11
12
// Local version replaces global one
12
13
try {
@@ -327,33 +328,7 @@ function processOptions(wpOpt) {
327
328
}
328
329
329
330
function 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 ) ;
357
332
358
333
let compiler ;
359
334
try {
@@ -372,7 +347,7 @@ function startDevServer(wpOpt, options) {
372
347
} ) ) ;
373
348
}
374
349
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/" ) ;
376
351
377
352
let server ;
378
353
try {
0 commit comments