@@ -55,22 +55,35 @@ const HOST = process.env.HOST || '0.0.0.0';
5555function run ( port ) {
5656 const protocol = process . env . HTTPS === 'true' ? 'https' : 'http' ;
5757
58- const formatUrl = hostname =>
59- url . format ( { protocol, hostname, port, pathname : '/' } ) ;
58+ const formatUrl = hostname => url . format ( {
59+ protocol,
60+ hostname,
61+ port,
62+ pathname : '/' ,
63+ } ) ;
64+ const prettyPrintUrl = hostname => url . format ( {
65+ protocol,
66+ hostname,
67+ port : chalk . bold ( port ) ,
68+ pathname : '/' ,
69+ } ) ;
6070
6171 const isUnspecifiedAddress = HOST === '0.0.0.0' || HOST === '::' ;
62- let prettyHost , lanAddress ;
72+ let prettyHost , lanAddress , prettyLanUrl ;
6373 if ( isUnspecifiedAddress ) {
6474 prettyHost = 'localhost' ;
6575 try {
6676 lanAddress = address . ip ( ) ;
77+ if ( lanAddress ) {
78+ prettyLanUrl = prettyPrintUrl ( lanAddress ) ;
79+ }
6780 } catch ( _e ) {
6881 // ignored
6982 }
7083 } else {
7184 prettyHost = HOST ;
7285 }
73- const prettyUrl = formatUrl ( prettyHost ) ;
86+ const prettyLocalUrl = prettyPrintUrl ( prettyHost ) ;
7487
7588 // Create a webpack compiler that is configured with custom messages.
7689 const compiler = createWebpackCompiler (
@@ -85,15 +98,11 @@ function run(port) {
8598 ) ;
8699 console . log ( ) ;
87100
88- if ( isUnspecifiedAddress && lanAddress ) {
89- console . log (
90- ` ${ chalk . bold ( 'Local:' ) } ${ chalk . cyan ( prettyUrl ) } `
91- ) ;
92- console . log (
93- ` ${ chalk . bold ( 'On Your Network:' ) } ${ chalk . cyan ( formatUrl ( lanAddress ) ) } `
94- ) ;
101+ if ( prettyLanUrl ) {
102+ console . log ( ` ${ chalk . bold ( 'Local:' ) } ${ prettyLocalUrl } ` ) ;
103+ console . log ( ` ${ chalk . bold ( 'On Your Network:' ) } ${ prettyLanUrl } ` ) ;
95104 } else {
96- console . log ( ` ${ chalk . cyan ( prettyUrl ) } ` ) ;
105+ console . log ( ` ${ prettyLocalUrl } ` ) ;
97106 }
98107
99108 console . log ( ) ;
0 commit comments