Html-webpack-plugin: html was not generated in watch mode, after changing one of the files

Created on 5 May 2020  路  5Comments  路  Source: jantimon/html-webpack-plugin

Expected behaviour

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

Current behaviour

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

Environment

Node: 12.13.0
OS: darwin 19.4.0
npm: 6.12.0
[email protected] 
[email protected] 

Config

module.exports = {
  entry: 'app.js',
  output: {
    path: 'dist',
    filename: 'index_bundle.js'
  },
  module: {
    rules: [
      ...
    ]
  }
  plugins: [
    new HtmlWebpackPlugin(),
    ...
  ]
}

Relevant Links

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:

new HtmlWebpackPlugin({
  cache: false
})

This should regenerate the template on every change (and will slow down your webpack build)

All 5 comments

The reason is probably here:

https://github.com/jantimon/html-webpack-plugin/blob/683435db8d3a7b41b69adf482c44aefa00858671/index.js#L168-L170

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.

Update

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:

https://github.com/jantimon/html-webpack-plugin/blob/683435db8d3a7b41b69adf482c44aefa00858671/index.js#L168-L170

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.

this was also released official as [email protected]

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amorphius picture amorphius  路  3Comments

ghaiklor picture ghaiklor  路  3Comments

rokoroku picture rokoroku  路  3Comments

hp8wvvvgnj6asjm7 picture hp8wvvvgnj6asjm7  路  3Comments

MatthewKosloski picture MatthewKosloski  路  3Comments