Skip to content

Commit 5181ac4

Browse files
committed
feat: make [hash] in chunk file names opt-in
1 parent e982e76 commit 5181ac4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/node/core/config/types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ export interface PkgConfigOptions {
127127
treeshake?: TreeshakingOptions
128128
/** @alpha */
129129
experimentalLogSideEffects?: boolean
130+
/**
131+
* Adds [hash] to chunk filenames, generally only useful if `@sanity/pkg-utils` is used to deploy a package directly to a CDN.
132+
* It's not needed when publishing to npm for consumption by other libraries, bundlers and frameworks.
133+
* @defaultValue false
134+
*/
135+
hashChunkFileNames?: boolean
130136
}
131137
/**
132138
* Default runtime of package exports

src/node/tasks/rollup/resolveRollupConfig.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,13 @@ export function resolveRollupConfig(
194194
outputOptions: {
195195
chunkFileNames: () => {
196196
const parts = outputExt.split('.')
197+
const prefix = config?.rollup?.hashChunkFileNames ? '[name]-[hash]' : '[name]'
197198

198199
if (parts.length === 3) {
199-
return `_chunks/[name]-[hash].${parts[2]}`
200+
return `_chunks/${prefix}.${parts[2]}`
200201
}
201202

202-
return `_chunks/[name]-[hash]${outputExt}`
203+
return `_chunks/${prefix}${outputExt}`
203204
},
204205
compact: minify,
205206
dir: outDir,

0 commit comments

Comments
 (0)