@@ -23,6 +23,7 @@ const serveIndex = require('serve-index');
2323const webpack = require ( 'webpack' ) ;
2424const webpackDevMiddleware = require ( 'webpack-dev-middleware' ) ;
2525const validateOptions = require ( 'schema-utils' ) ;
26+ const isAbsoluteUrl = require ( 'is-absolute-url' ) ;
2627const updateCompiler = require ( './utils/updateCompiler' ) ;
2728const createLogger = require ( './utils/createLogger' ) ;
2829const getCertificate = require ( './utils/getCertificate' ) ;
@@ -153,23 +154,25 @@ class Server {
153154 }
154155
155156 setupProgressPlugin ( ) {
156- const progressPlugin = new webpack . ProgressPlugin (
157- ( percent , msg , addInfo ) => {
158- percent = Math . floor ( percent * 100 ) ;
157+ // for CLI output
158+ new webpack . ProgressPlugin ( {
159+ profile : ! ! this . options . profile ,
160+ } ) . apply ( this . compiler ) ;
159161
160- if ( percent === 100 ) {
161- msg = 'Compilation completed' ;
162- }
162+ // for browser console output
163+ new webpack . ProgressPlugin ( ( percent , msg , addInfo ) => {
164+ percent = Math . floor ( percent * 100 ) ;
163165
164- if ( addInfo ) {
165- msg = ` ${ msg } ( ${ addInfo } )` ;
166- }
166+ if ( percent === 100 ) {
167+ msg = 'Compilation completed' ;
168+ }
167169
168- this . sockWrite ( this . sockets , 'progress-update' , { percent, msg } ) ;
170+ if ( addInfo ) {
171+ msg = `${ msg } (${ addInfo } )` ;
169172 }
170- ) ;
171173
172- progressPlugin . apply ( this . compiler ) ;
174+ this . sockWrite ( this . sockets , 'progress-update' , { percent, msg } ) ;
175+ } ) . apply ( this . compiler ) ;
173176 }
174177
175178 setupApp ( ) {
@@ -356,7 +359,7 @@ class Server {
356359 contentBase . forEach ( ( item ) => {
357360 this . app . get ( '*' , express . static ( item ) ) ;
358361 } ) ;
359- } else if ( / ^ ( h t t p s ? : ) ? \/ \/ / . test ( contentBase ) ) {
362+ } else if ( isAbsoluteUrl ( String ( contentBase ) ) ) {
360363 this . log . warn (
361364 'Using a URL as contentBase is deprecated and will be removed in the next major version. Please use the proxy option instead.'
362365 ) ;
@@ -408,8 +411,8 @@ class Server {
408411 this . app . get ( '*' , serveIndex ( item ) ) ;
409412 } ) ;
410413 } else if (
411- ! / ^ ( h t t p s ? : ) ? \/ \/ / . test ( contentBase ) &&
412- typeof contentBase !== 'number'
414+ typeof contentBase !== 'number' &&
415+ ! isAbsoluteUrl ( String ( contentBase ) )
413416 ) {
414417 this . app . get ( '*' , serveIndex ( contentBase ) ) ;
415418 }
@@ -418,13 +421,13 @@ class Server {
418421 setupWatchStaticFeature ( ) {
419422 const contentBase = this . options . contentBase ;
420423
421- if (
422- / ^ ( h t t p s ? : ) ? \/ \/ / . test ( contentBase ) ||
423- typeof contentBase === 'number'
424- ) {
424+ if ( isAbsoluteUrl ( String ( contentBase ) ) || typeof contentBase === 'number' ) {
425425 throw new Error ( 'Watching remote files is not supported.' ) ;
426426 } else if ( Array . isArray ( contentBase ) ) {
427427 contentBase . forEach ( ( item ) => {
428+ if ( isAbsoluteUrl ( String ( item ) ) ) {
429+ throw new Error ( 'Watching remote files is not supported.' ) ;
430+ }
428431 this . _watch ( item ) ;
429432 } ) ;
430433 } else {
0 commit comments