Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html was not generated in watch mode, after changing one of the files #1432

Closed
gevorg-martir opened this issue May 5, 2020 · 5 comments
Closed

Comments

@gevorg-martir
Copy link

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

@jantimon
Copy link
Owner

The reason is probably here:

if (isCompilationCached && self.options.cache && assetJson === self.assetJson) {
return callback();
} else {

Can you try the following:

new HtmlWebpackPlugin({
  cache: false
})

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

@daniele-orlando
Copy link

daniele-orlando commented May 20, 2020

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.

@FedeBev
Copy link

FedeBev commented Jun 1, 2020

The reason is probably here:

if (isCompilationCached && self.options.cache && assetJson === self.assetJson) {
return callback();
} else {

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.

@jantimon
Copy link
Owner

jantimon commented Nov 2, 2020

fixed in [email protected]

@jantimon
Copy link
Owner

jantimon commented Feb 3, 2021

this was also released official as [email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants