@@ -11,14 +11,18 @@ import yargs from 'yargs';
1111import { HttpServer } from './server' ;
1212import { setupBazelWatcherSupport } from './ibazel' ;
1313
14- const { rootPaths, historyApiFallback, enableDevUi, environmentVariables, port, relaxCors} = yargs (
15- process . argv . slice ( 2 ) ,
16- )
14+ const {
15+ rootPaths,
16+ historyApiFallback,
17+ enableDevUi,
18+ environmentVariables,
19+ port : cliPort ,
20+ relaxCors,
21+ } = yargs ( process . argv . slice ( 2 ) )
1722 . strict ( )
1823 . option ( 'port' , {
1924 type : 'number' ,
20- default : process . env [ 'PORT' ] !== undefined ? Number ( process . env [ 'PORT' ] ) : 4200 ,
21- defaultDescription : '${PORT}, or 4200 if unset' ,
25+ default : 4200 ,
2226 } )
2327 . option ( 'historyApiFallback' , { type : 'boolean' , default : false } )
2428 . option ( 'rootPaths' , { type : 'array' , string : true , default : [ '' ] } )
@@ -27,6 +31,12 @@ const {rootPaths, historyApiFallback, enableDevUi, environmentVariables, port, r
2731 . option ( 'relaxCors' , { type : 'boolean' , default : false } )
2832 . parseSync ( ) ;
2933
34+ let port = cliPort ;
35+ // Process environment port always overrides the CLI, or rule attribute-specified port.
36+ if ( process . env . PORT !== undefined ) {
37+ port = Number ( process . env . PORT ) ;
38+ }
39+
3040// In non-test executions, we will never allow for the browser-sync dev UI.
3141const enableUi = process . env . TEST_TARGET === undefined && enableDevUi ;
3242const server = new HttpServer (
0 commit comments