I would expect that after every change in any other file rather than template file (example js, css, etc). I should get regenerated html file in watch mode
Now html-webpack-plugin generates html file only first time and usually people use clean-webpack-plugin, and the result is missing html file after any change inside any file js,css, etc
Node: 12.13.0
OS: darwin 19.4.0
npm: 6.12.0
[email protected]
[email protected]
module.exports = {
entry: 'app.js',
output: {
path: 'dist',
filename: 'index_bundle.js'
},
module: {
rules: [
...
]
}
plugins: [
new HtmlWebpackPlugin(),
...
]
}
The reason is probably here:
Can you try the following:
new HtmlWebpackPlugin({
cache: false
})
This should regenerate the template on every change (and will slow down your webpack build)
I can confirm that
new HtmlWebpackPlugin({
cache: false
})
fixes the problem.
The problem in my case does not arise from using the clean-webpack-plugin, in fact removing it does not fix the problem.
The only way is disabling the html-webpack-plugin cache.
The reason is probably here:
Can you try the following:
new HtmlWebpackPlugin({ cache: false })This should regenerate the template on every change (and will slow down your webpack build)
I can confirm too, that fixes the problem.
fixed in [email protected]
this was also released official as [email protected]
Most helpful comment
The reason is probably here:
https://github.com/jantimon/html-webpack-plugin/blob/683435db8d3a7b41b69adf482c44aefa00858671/index.js#L168-L170
Can you try the following:
This should regenerate the template on every change (and will slow down your webpack build)