question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack watch mode 4.42.1, and html-webpack-plugin 4.0.4 with cache enabled results that templates get erased

See original GitHub issue

Given: osx 10.14.6 node: 13.6.0 webpack: 4.42.1 html-webpack-plugin: 4.0.4 html-webpack-harddisk-plugin: 1.0.1

When running webpack in watch mode and html-webpack-plugin configured by default results that templates get erased after some time. Problem can be solved by providing cache: false to html-webpack-plugin settings.

Also, webpack configured to use devMiddleware so actual javascript is not emitted.

Maybe I can provide some additional info? If so, I’ll be glad.

Thank you!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
koen-devcommented, Feb 26, 2021

@Reeywhaar Thanks for the fast reply!

I started playing with the configuration of clean-webpack-plugin too. I generate .cshtml outside of the output.path which is why CleanWebpackPlugin didn’t delete them correctly.

So for me the following config works:

new CleanWebpackPlugin({
    dry: false,
    dangerouslyAllowCleanPatternsOutsideProject: true,
})

Thank you so much for this! You have no idea how long I have been looking for the reason why my webpack-dev-server was stuck. 🎉

1reaction
Reeywhaarcommented, Apr 8, 2020

Ok, so problem is that I also use clean-webpack-plugin. Steps are goes like:

  • initial compilation:
    • clean-webpack-plugin clears build directory
    • harddisk-plugin writes build/template.html, build/some_other_page.html
  • second compilation (I actually change content in js)
    • harddisk-plugin either writes all, or template.html or some_other_page.html depending whether content changed (like if we injected js with different hash).
    • clean-webpack-plugin either removes all, template.html or some_other_page.html. I am not yet sure what is his strategy.
  • third compilation (i don’t change anything, and just hit cmd+s)
    • harddisk-plugin do not emit anything because of cache
    • clean-webpack-plugin removes all (at least it can, but no 100% guarantee)

Interesting how at initial compilation clean-webpack-plugin goes first and harddisk-plugin second, but consequent compilation order is swapped.

So, I’m sure it’s not harddisk-plugin problem anymore but rather proper configuration of clean-webpack-plugin. What do you think? Should I close the issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

html was not generated in watch mode, after changing one of ...
The only way is disabling the html-webpack-plugin cache.
Read more >
How to watch index.html using webpack-dev-server and html ...
The problem is that index.html is not being watched by Webpack. It only watches those files that are "required" or "imported" somewhere in...
Read more >
html-webpack-plugin - npm
This is a webpack plugin that simplifies creation of HTML files to serve your webpack bundles. This is especially useful for webpack bundles ......
Read more >
Webpack 4 Template - Customizations
We will now look into how to write our own configurations so that we can have greater control on what webpack should do....
Read more >
Third-party software dependencies | Elastic Cloud Enterprise ...
Library Version Optional/Required Packaged org.scala‑lang.modules 1.1.1 Required Yes org.apache.zookeeper 3.5.3‑beta Required Yes org.apache.curator 4.2.0 Required Yes
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found