-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Missing assets after recompilation in development #1709
Comments
Changing Example of template (with the following rule: <!DOCTYPE HTML>
<html lang="en">
<body>
<%= require('./2.aaa').default %>
</body>
</html> Also, I am not using the Lines 719 to 731 in 9c9786a
|
Monkey patch: diff --git a/lib/cached-child-compiler.js b/lib/cached-child-compiler.js
index ad5b67e0b21b26cf64aaf831ff9df05d4e3392a8..aea5d0bb0ffa0ca78c315dc2169b49d483d930dc 100644
--- a/lib/cached-child-compiler.js
+++ b/lib/cached-child-compiler.js
@@ -313,22 +313,8 @@ class PersistentChildCompilerSingletonPlugin {
* @returns {Promise<boolean>}
*/
isCacheValid (snapshot, mainCompilation) {
- if (!this.compilationState.isVerifyingCache) {
- return Promise.reject(new Error('Cache validation can only be done right before the compilation starts'));
- }
- // If there are no entries we don't need a new child compilation
- if (this.compilationState.entries.length === 0) {
- return Promise.resolve(true);
- }
- // If there are new entries the cache is invalid
- if (this.compilationState.entries !== this.compilationState.previousEntries) {
- return Promise.resolve(false);
- }
- // Mark the cache as invalid if there is no snapshot
- if (!snapshot) {
- return Promise.resolve(false);
- }
- return fileWatcherApi.isSnapShotValid(snapshot, mainCompilation);
+ // https://github.com/jantimon/html-webpack-plugin/issues/1709
+ return Promise.resolve(false);
}
/** |
I have similar problem with image assets used in index.html via HtmlWebpackPlugin. Production build and first execution of watch is OK, but as soon as I modify any JS file - images disapper from dist folder. If I modify index.html - images reappear in dist folder again. Tried on both windows 10 and ubuntu 20.04 with node@14.16. To reproduce try this: https://github.com/fretfan/image-watch-bug It was happening occasionlaly with older versions of webpack and HtmlWebpackPlugin. I was assuming, I was accesing resources faster then rebuild was complete. Changing some random JS file was nudging webpack to generate missing image asset and it was fine for some time. Now with the newest version of webpack and HtmlWebpackPlugin - this bug became consistent on second watch/reload. |
@jantimon, any news? |
@fretfan I have this issue exectly like you discribe, with "webpack": "^5.65.0","webpack-dev-server": "^4.7.2", "html-webpack-plugin": "^5.5.0", |
Same |
i have this bug on: |
Looks like this is still the case. |
For those who came here from a google search, setting up Credit goes to https://stackoverflow.com/questions/72498866/webpack-images-disappear-after-browser-refresh-using-webpack-dev-server |
But after changes and recompilations hashed js files stack too much which is unnessary. |
Yeah, it is a bug, we want to fix it, let's close in favor of #1639, because it is the same, sorry for long answer |
Fixed in main, release will be soon |
Current behaviour 💣
I am writting a plugin to process assets produced by webpack:
My
index.ejs
requires external resources (such as an image for the favicon). When compiling in production mode I have the correct list of assets. Same for the first compilation in development using webpack-dev-server. But when recompiling due to a change in a file outside ofindex.ejs
and associated required resources then this resources are not part of the assets list.It is expected? (I am observing similar issue with webpack-manifest-plugin, instead of my own custom plugin, which makes me think issue is in
html-webpack-plugin
. Also, reproduction example shows the bug is present for bothfile-loader
andasset/resource
methods.Reproduction Example 👾
https://github.com/vhiairrassary/html-webpack-plugin-asset-bug
Launch webpack with
./node_modules/.bin/webpack serve --mode development
(all files are correctly emitted):Modify string in
console.log
fromsrc/index.js
to trigger re-compilation (index.html
is part of emitted assets butnot the files required inside
index.ejs
:2.aaa
and2.bbb
):Modify
index.ejs
(this time all files are correctly emitted):The text was updated successfully, but these errors were encountered: