nx/packages/webpack/src/utils/hash-format.ts
2022-09-12 21:19:50 +01:00

27 lines
782 B
TypeScript

export interface HashFormat {
chunk: string;
extract: string;
file: string;
script: string;
}
export function getOutputHashFormat(option: string, length = 20): HashFormat {
const hashFormats: { [option: string]: HashFormat } = {
none: { chunk: '', extract: '', file: '', script: '' },
media: { chunk: '', extract: '', file: `.[hash:${length}]`, script: '' },
bundles: {
chunk: `.[chunkhash:${length}]`,
extract: `.[contenthash:${length}]`,
file: '',
script: `.[contenthash:${length}]`,
},
all: {
chunk: `.[chunkhash:${length}]`,
extract: `.[contenthash:${length}]`,
file: `.[contenthash:${length}]`,
script: `.[contenthash:${length}]`,
},
};
return hashFormats[option] || hashFormats['none'];
}