File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,10 @@ if (semver.satisfies(process.version, '8.6.0 - 9')) {
6262 tls . DEFAULT_ECDH_CURVE = 'auto' ;
6363}
6464
65+ if ( ! process . env . WEBPACK_DEV_SERVER ) {
66+ process . env . WEBPACK_DEV_SERVER = true ;
67+ }
68+
6569class Server {
6670 constructor ( compiler , options = { } , _log ) {
6771 if ( options . lazy && ! options . filename ) {
@@ -753,6 +757,10 @@ class Server {
753757 if ( fn ) {
754758 fn . call ( this . listeningApp , err ) ;
755759 }
760+
761+ if ( this . options . onListening ) {
762+ this . options . onListening ( ) ;
763+ }
756764 } ) ;
757765 }
758766
Original file line number Diff line number Diff line change @@ -474,4 +474,30 @@ describe('Server', () => {
474474 afterAll ( testServer . close ) ;
475475 } ) ;
476476 } ) ;
477+
478+ describe ( 'WEBPACK_DEV_SERVER environment variable' , ( ) => {
479+ const OLD_ENV = process . env ;
480+
481+ beforeEach ( ( ) => {
482+ // this is important - it clears the cache
483+ jest . resetModules ( ) ;
484+
485+ process . env = { ...OLD_ENV } ;
486+
487+ delete process . env . WEBPACK_DEV_SERVER ;
488+ } ) ;
489+
490+ afterEach ( ( ) => {
491+ process . env = OLD_ENV ;
492+ } ) ;
493+
494+ it ( 'should be present' , ( ) => {
495+ expect ( process . env . WEBPACK_DEV_SERVER ) . toBeUndefined ( ) ;
496+
497+ // eslint-disable-next-line global-require
498+ require ( '../lib/Server' ) ;
499+
500+ expect ( process . env . WEBPACK_DEV_SERVER ) . toBe ( true ) ;
501+ } ) ;
502+ } ) ;
477503} ) ;
You can’t perform that action at this time.
0 commit comments