@@ -125,16 +125,20 @@ export class FreshPlugin {
125125 // Ensure hot chunks are resolved from correct path, they can't contain compilationId in name
126126 compilation . outputOptions . publicPath = "/" ;
127127 {
128- // Fresh has no native support for content-addressed static assets, instead there is such paths.
129- // We also don't need webpack to use contentHash, as the paths are already made unique.
130- // TODO: It would be better to use content-addressing for production updates and better CDN support,
131- // but support for that needs to be added upstream.
132- compilation . outputOptions . filename =
133- `_fresh/js/${ compilationId } /[id].mjs` ;
134- compilation . outputOptions . chunkFilename =
135- `_fresh/js/${ compilationId } /[id].mjs` ;
128+ // Chunks are content-addressed in prod, and have readable names using standard fresh cache pruning in dev
129+ if ( compiler . options . mode === "production" ) {
130+ compilation . outputOptions . filename = `_fresh/js/c/[chunkhash].mjs` ;
131+ compilation . outputOptions . chunkFilename =
132+ `_fresh/js/c/[chunkhash].mjs` ;
133+ } else {
134+ compilation . outputOptions . filename =
135+ `_fresh/js/${ compilationId } /[id].mjs` ;
136+ compilation . outputOptions . chunkFilename =
137+ `_fresh/js/${ compilationId } /[id].mjs` ;
138+ }
139+ // Assets are always content-addressed
136140 compilation . outputOptions . assetModuleFilename =
137- `_fresh/js/${ compilationId } /[hash][ext][query]` ;
141+ `_fresh/js/c /[hash][ext][query]` ;
138142 }
139143
140144 compilation . hooks . processAssets . tapPromise (
0 commit comments