I'm getting this error when trying to run webpack build
with hashing in my config:
ERROR in chunk main [entry]
[name].[chunkhash].js
Cannot use [chunkhash] or [contenthash] for chunk in '[name].[chunkhash].js'
(use [hash] instead)
Webpack dev server runs fine
What is the reason for this?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With