assetModuleFilename doesn't affect chunkhash of final javascript file
See original GitHub issueBug report
What is the current behavior?
Changing assetModuleFilename
in configuration doesn’t change chunkhash
of files using import
ed images.
this can lead to various caching problems (browser, procies, cdn etc)
If the current behavior is a bug, please provide the steps to reproduce.
you can find an example here https://github.com/stuff/webpack-assets-bug
webpack config:
{
mode: 'development',
entry: './src/index.js',
output: {
filename: '[name].[chunkhash].js',
path: path.resolve(__dirname, 'dist'),
assetModuleFilename: 'img/[name]-[hash][ext]',
},
module: {
rules: [
{
test: /\.(png|jpg|gif)$/i,
type: 'asset/resource',
},
],
},
}
both assetModuleFilename: 'img/[name]-[hash][ext]'
and assetModuleFilename: 'assets/[name]-[hash][ext]'
results in a js file named main.09783b82d14c2e26304e.js
actually resulting in 2 differents files with:
eval("module.exports = __webpack_require__.p + \"img/oc-c1f902d15bfedbcc2538.png\"
eval("module.exports = __webpack_require__.p + \"assets/oc-c1f902d15bfedbcc2538.png\";
What is the expected behavior?
I would expect that the final js filename has a different chunkhash
Other relevant information: webpack version: 5.64.4 Node.js version: v16.13.0 Operating System: ubuntu 20.04
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
@alexander-akait I think you did not get what @stuff is expecting… It is ok that asset has same hash. it is not ok that js chunk that uses this asset has same hash. (pls note asset name are different
img/
vsasset/
prefix)exactly this 😉