Skip to content

Commit

Permalink
feat: make [hash] in chunk file names opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Feb 26, 2024
1 parent e982e76 commit 5181ac4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/node/core/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ export interface PkgConfigOptions {
treeshake?: TreeshakingOptions
/** @alpha */
experimentalLogSideEffects?: boolean
/**
* Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN.
* It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks.
* @defaultValue false
*/
hashChunkFileNames?: boolean
}
/**
* Default runtime of package exports
Expand Down
5 changes: 3 additions & 2 deletions src/node/tasks/rollup/resolveRollupConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,13 @@ export function resolveRollupConfig(
outputOptions: {
chunkFileNames: () => {
const parts = outputExt.split('.')
const prefix = config?.rollup?.hashChunkFileNames ? '[name]-[hash]' : '[name]'

if (parts.length === 3) {
return `_chunks/[name]-[hash].${parts[2]}`
return `_chunks/${prefix}.${parts[2]}`
}

return `_chunks/[name]-[hash]${outputExt}`
return `_chunks/${prefix}${outputExt}`
},
compact: minify,
dir: outDir,
Expand Down

0 comments on commit 5181ac4

Please sign in to comment.