@@ -25,6 +25,7 @@ import * as path from 'path';
25
25
import { Observable , Subscriber , catchError , defaultIfEmpty , from , of , switchMap } from 'rxjs' ;
26
26
import { Configuration } from 'webpack' ;
27
27
import { ExecutionTransformer } from '../../transforms' ;
28
+ import { normalizeFileReplacements } from '../../utils' ;
28
29
import { OutputHashing } from '../browser-esbuild/schema' ;
29
30
import { findTests , getTestEntrypoints } from './find-tests' ;
30
31
import { Schema as KarmaBuilderOptions } from './schema' ;
@@ -400,17 +401,24 @@ async function initializeApplication(
400
401
index : false ,
401
402
outputHashing : OutputHashing . None ,
402
403
optimization : false ,
403
- sourceMap : {
404
- scripts : true ,
405
- styles : true ,
406
- vendor : true ,
407
- } ,
404
+ sourceMap : options . codeCoverage
405
+ ? {
406
+ scripts : true ,
407
+ styles : true ,
408
+ vendor : true ,
409
+ }
410
+ : options . sourceMap ,
408
411
instrumentForCoverage,
409
412
styles : options . styles ,
413
+ scripts : options . scripts ,
410
414
polyfills,
411
415
webWorkerTsConfig : options . webWorkerTsConfig ,
412
416
watch : options . watch ?? ! karmaOptions . singleRun ,
413
417
stylePreprocessorOptions : options . stylePreprocessorOptions ,
418
+ inlineStyleLanguage : options . inlineStyleLanguage ,
419
+ fileReplacements : options . fileReplacements
420
+ ? normalizeFileReplacements ( options . fileReplacements , './' )
421
+ : undefined ,
414
422
} ;
415
423
416
424
// Build tests with `application` builder, using test files as entry points.
@@ -447,6 +455,16 @@ async function initializeApplication(
447
455
} ;
448
456
449
457
karmaOptions . files ??= [ ] ;
458
+ if ( options . scripts ?. length ) {
459
+ // This should be more granular to support named bundles.
460
+ // However, it replicates the behavior of the Karma Webpack-based builder.
461
+ karmaOptions . files . push ( {
462
+ pattern : `${ outputPath } /scripts.js` ,
463
+ watched : false ,
464
+ type : 'js' ,
465
+ } ) ;
466
+ }
467
+
450
468
karmaOptions . files . push (
451
469
// Serve global setup script.
452
470
{ pattern : `${ outputPath } /${ mainName } .js` , type : 'module' , watched : false } ,
0 commit comments