Skip to content

Commit

Permalink
add first 8 chars of contenthash to .js filenames, re #11670
Browse files Browse the repository at this point in the history
  • Loading branch information
whatisgalen committed Jan 10, 2025
1 parent 43d034e commit 52744ae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion webpack/webpack-utils/build-filepath-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ function buildFilepathLookup(path, staticUrlPrefix) {
}
const extension = file.match(/[^.]+$/).toString();
const extensionReplacementRegex = new RegExp(`\\.${extension}$`);
const relativePath = file.replace(path,'').replace(/\\/g, '/').replace(/^\//,'');

if (extension === 'js') {
lookup[file.replace(path,'').replace(/\\/g, '/').replace(extensionReplacementRegex,'').replace(/^\//,'')] = {"import": file, "filename": `${prefix}/[name].${extension}`};
lookup[relativePath.replace(extensionReplacementRegex,'')] = {
"import": file,
"filename": `${prefix}/[name].[contenthash:8].${extension}`
};
}
else if (extension === 'css' || extension === 'scss') {
lookup[Path.join('css', file.replace(path,'')).replace(/\\/g, '/').replace(extensionReplacementRegex,'').replace(/^\//,'')] = { 'import': file };
Expand Down

0 comments on commit 52744ae

Please sign in to comment.