Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some webpack-built files are named with their file hash while others aren't #11670

Open
whatisgalen opened this issue Dec 3, 2024 · 0 comments
Labels
Type: Bug Something isn't working Webpack

Comments

@whatisgalen
Copy link
Member

whatisgalen commented Dec 3, 2024

A common use case is that a developer has updated their project and pushes these updates to a production server (run webpack build, collectstatic, etc.) but end-users' browsers are still caching the old files. There's a cache-bursting strategy built into the logic of how webpack names these files:

resolve({
            entry: {
                ...archesCoreEntryPointConfiguration,
                ...archesApplicationsEntrypointConfiguration,
                ...projectEntryPointConfiguration,
                ...CSSFilepathLookup,
            },
            devServer: {
                port: WEBPACK_DEVELOPMENT_SERVER_PORT,
            },
            output: {
                path: Path.resolve(__dirname, APP_ROOT, 'media', 'build'),
                publicPath: STATIC_URL,
                filename: '[name].[contenthash].js', // Adds a hash to all entry points
                chunkFilename: '[id].[contenthash].js', // Adds a hash to all dynamically imported chunks
                clean: true,
                assetModuleFilename: 'img/[hash][ext][query]',
            },
            ...

The contenthash is used in creating the name of each file, capturing its updated state which then forces browsers to get the new files from the server. However when npm run build_production gets run, only so-called chunkFiles (.chunk.js) get their content hash mixed into their file names. Files like search.js or graph.js do not contain any hash values in the filenames, despite the explicit logic above in the webpack config.

@whatisgalen whatisgalen added the Type: Bug Something isn't working label Dec 3, 2024
@chiatt chiatt added this to pipeline Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working Webpack
Projects
Status: No status
Development

No branches or pull requests

1 participant