Cannot use [chunkhash] or [contenthash] for chunk in '[name].[chunkhash].js' (use [hash] instead)

Commented out new webpack.HotModuleReplacementPlugin() in the plugins helped fix this


My solution was to change the filename depending on whether the mode is production or development:

filename: mode === 'production' ? '[name].[chunkhash].js' : '[name].[hash].js',

Fixed my problem and still able to use chunkhash for my production filenames as well as HotModuleReplacementPlugin.


This worked for me too...thanks to @pizzaae. One thing to note, is that you never want to enable HMR during production. Having different Webpack configs for Prod and Dev can help if you want to use both HotModuleReplacementPlugin and chunkash.

Tags:

Webpack