Skip to content

Commit f3c8268

Browse files
committed
fix(@angular/build): maintain media output hashing with vitest unit-testing
To ensure that output media files do not overwrite each other if source media files use the same base file name but are contained in different directories, the output hashing option from the build target will now keep the `media` option enabled if configured. (cherry picked from commit f806f64)
1 parent 99526bd commit f3c8268

File tree

1 file changed

+12
-1
lines changed
  • packages/angular/build/src/builders/unit-test

1 file changed

+12
-1
lines changed

packages/angular/build/src/builders/unit-test/builder.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ export type { UnitTestBuilderOptions };
3636

3737
type VitestCoverageOption = Exclude<import('vitest/node').InlineConfig['coverage'], undefined>;
3838

39+
function adjustOutputHashing(hashing?: OutputHashing): OutputHashing {
40+
switch (hashing) {
41+
case OutputHashing.All:
42+
case OutputHashing.Media:
43+
// Ensure media is continued to be hashed to avoid overwriting of output media files
44+
return OutputHashing.Media;
45+
default:
46+
return OutputHashing.None;
47+
}
48+
}
49+
3950
/**
4051
* @experimental Direct usage of this function is considered experimental.
4152
*/
@@ -135,7 +146,7 @@ export async function* execute(
135146
ssr: false,
136147
prerender: false,
137148
sourceMap: { scripts: true, vendor: false, styles: false },
138-
outputHashing: OutputHashing.None,
149+
outputHashing: adjustOutputHashing(buildTargetOptions.outputHashing),
139150
optimization: false,
140151
tsConfig: normalizedOptions.tsConfig,
141152
entryPoints,

0 commit comments

Comments
 (0)