@@ -17,6 +17,7 @@ import {
1717 AssetPatternClass ,
1818 ExtraEntryPoint ,
1919 ExtraEntryPointClass ,
20+ OutputHashing ,
2021} from '../../builders/browser/schema' ;
2122import { WebpackConfigOptions } from '../../utils/build-options' ;
2223import { VERSION } from '../../utils/package-version' ;
@@ -28,25 +29,40 @@ export interface HashFormat {
2829 script : string ;
2930}
3031
31- export function getOutputHashFormat ( option : string , length = 20 ) : HashFormat {
32- const hashFormats : { [ option : string ] : HashFormat } = {
33- none : { chunk : '' , extract : '' , file : '' , script : '' } ,
34- media : { chunk : '' , extract : '' , file : `.[hash:${ length } ]` , script : '' } ,
35- bundles : {
36- chunk : `.[contenthash:${ length } ]` ,
37- extract : `.[contenthash:${ length } ]` ,
38- file : '' ,
39- script : `.[hash:${ length } ]` ,
40- } ,
41- all : {
42- chunk : `.[contenthash:${ length } ]` ,
43- extract : `.[contenthash:${ length } ]` ,
44- file : `.[hash:${ length } ]` ,
45- script : `.[hash:${ length } ]` ,
46- } ,
47- } ;
48-
49- return hashFormats [ option ] || hashFormats [ 'none' ] ;
32+ export function getOutputHashFormat ( outputHashing = OutputHashing . None , length = 20 ) : HashFormat {
33+ const hashTemplate = `.[contenthash:${ length } ]` ;
34+
35+ switch ( outputHashing ) {
36+ case 'media' :
37+ return {
38+ chunk : '' ,
39+ extract : '' ,
40+ file : hashTemplate ,
41+ script : '' ,
42+ } ;
43+ case 'bundles' :
44+ return {
45+ chunk : hashTemplate ,
46+ extract : hashTemplate ,
47+ file : '' ,
48+ script : hashTemplate ,
49+ } ;
50+ case 'all' :
51+ return {
52+ chunk : hashTemplate ,
53+ extract : hashTemplate ,
54+ file : hashTemplate ,
55+ script : hashTemplate ,
56+ } ;
57+ case 'none' :
58+ default :
59+ return {
60+ chunk : '' ,
61+ extract : '' ,
62+ file : '' ,
63+ script : '' ,
64+ } ;
65+ }
5066}
5167
5268export type NormalizedEntryPoint = Required < ExtraEntryPointClass > ;
0 commit comments