@@ -25,6 +25,7 @@ import * as path from 'path';
2525import { Observable , Subscriber , catchError , defaultIfEmpty , from , of , switchMap } from 'rxjs' ;
2626import { Configuration } from 'webpack' ;
2727import { ExecutionTransformer } from '../../transforms' ;
28+ import { normalizeFileReplacements } from '../../utils' ;
2829import { OutputHashing } from '../browser-esbuild/schema' ;
2930import { findTests , getTestEntrypoints } from './find-tests' ;
3031import { Schema as KarmaBuilderOptions } from './schema' ;
@@ -400,17 +401,24 @@ async function initializeApplication(
400401 index : false ,
401402 outputHashing : OutputHashing . None ,
402403 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 ,
408411 instrumentForCoverage,
409412 styles : options . styles ,
413+ scripts : options . scripts ,
410414 polyfills,
411415 webWorkerTsConfig : options . webWorkerTsConfig ,
412416 watch : options . watch ?? ! karmaOptions . singleRun ,
413417 stylePreprocessorOptions : options . stylePreprocessorOptions ,
418+ inlineStyleLanguage : options . inlineStyleLanguage ,
419+ fileReplacements : options . fileReplacements
420+ ? normalizeFileReplacements ( options . fileReplacements , './' )
421+ : undefined ,
414422 } ;
415423
416424 // Build tests with `application` builder, using test files as entry points.
@@ -447,6 +455,16 @@ async function initializeApplication(
447455 } ;
448456
449457 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+
450468 karmaOptions . files . push (
451469 // Serve global setup script.
452470 { pattern : `${ outputPath } /${ mainName } .js` , type : 'module' , watched : false } ,
0 commit comments