@@ -60,6 +60,7 @@ export interface DevServerBuilderOptions {
6060 verbose ?: boolean ;
6161}
6262
63+ type DevServerBuilderOptionsKeys = Extract < keyof DevServerBuilderOptions , string > ;
6364
6465export class DevServerBuilder implements Builder < DevServerBuilderOptions > {
6566
@@ -392,24 +393,30 @@ export class DevServerBuilder implements Builder<DevServerBuilderOptions> {
392393 const architect = this . context . architect ;
393394 const [ project , target , configuration ] = options . browserTarget . split ( ':' ) ;
394395
395- const overrides = {
396- // Override browser build watch setting.
397- watch : options . watch ,
398-
399- // Update the browser options with the same options we support in serve, if defined.
400- ...( options . optimization !== undefined ? { optimization : options . optimization } : { } ) ,
401- ...( options . aot !== undefined ? { aot : options . aot } : { } ) ,
402- ...( options . sourceMap !== undefined ? { sourceMap : options . sourceMap } : { } ) ,
403- ...( options . vendorSourceMap !== undefined ?
404- { vendorSourceMap : options . vendorSourceMap } : { } ) ,
405- ...( options . evalSourceMap !== undefined ? { evalSourceMap : options . evalSourceMap } : { } ) ,
406- ...( options . vendorChunk !== undefined ? { vendorChunk : options . vendorChunk } : { } ) ,
407- ...( options . commonChunk !== undefined ? { commonChunk : options . commonChunk } : { } ) ,
408- ...( options . baseHref !== undefined ? { baseHref : options . baseHref } : { } ) ,
409- ...( options . progress !== undefined ? { progress : options . progress } : { } ) ,
410- ...( options . poll !== undefined ? { poll : options . poll } : { } ) ,
411- ...( options . verbose !== undefined ? { verbose : options . verbose } : { } ) ,
412- } ;
396+ const overridesOptions : DevServerBuilderOptionsKeys [ ] = [
397+ 'watch' ,
398+ 'optimization' ,
399+ 'aot' ,
400+ 'sourceMap' ,
401+ 'vendorSourceMap' ,
402+ 'evalSourceMap' ,
403+ 'vendorChunk' ,
404+ 'commonChunk' ,
405+ 'baseHref' ,
406+ 'progress' ,
407+ 'poll' ,
408+ 'verbose' ,
409+ ] ;
410+
411+ // remove options that are undefined or not to be overrriden
412+ const overrides = ( Object . keys ( options ) as DevServerBuilderOptionsKeys [ ] )
413+ . filter ( key => options [ key ] !== undefined && overridesOptions . includes ( key ) )
414+ . reduce < Partial < BrowserBuilderSchema > > ( ( previous , key ) => (
415+ {
416+ ...previous ,
417+ [ key ] : options [ key ] ,
418+ }
419+ ) , { } ) ;
413420
414421 const browserTargetSpec = { project, target, configuration, overrides } ;
415422 const builderConfig = architect . getBuilderConfiguration < BrowserBuilderSchema > (
0 commit comments