-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Options.cache does not prevent unchanged HTML pages from being rebuilt in watch mode #962
Comments
However after webpack upgrade to version 4,
In webpack@4, the id is change between 1 and 0 every time when you change any file. I know that id is always 0 in webpack@2.3.3. The same chunk's id should not change. The My suggestion is to provide an unit key when new HtmlWebpackPlugin and pass the key to In
and in
|
thanks for looking into the performance of the plugin - I am very very happy for your support. For multiple html files the performance is quite low. If you add multiple instances of the html-webpack-plugin the plugin attaches multiple child compiler to webpack. To suggestion on how we might improve: 1. Reduce the amount of child compilersWe could create a Pseudo code (just to illustrate the concept)
This would reduce the amount of child compilers to one even if there are many different templates. 2. Track the timestamps of the compilation instead of the hash@sokra suggested that we might use the timestamps of all dependencies to check if we need to recompile at all like the normal module does: https://github.com/webpack/webpack/blob/3415a983301bbaeffd1bf250e3c7b139a392315b/lib/NormalModule.js#L463-L485 We could store all files of our dependency tree and the time of the compilation. |
See #965 for a possible solution to 2. Track the timestamps of the compilation instead of the hash |
I opened a pr #967 which managed to solve "1. Reduce the amount of child compilers" and still passes all tests. It also knows which files where involved so maybe we can get "2. Track the timestamps of the compilation instead of the hash" also done. |
The second part is done in #972 - @dwoznicki could you please take a look? :) |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Background
I'm using
html-webpack-plugin
to generate around 25 HTML files for my project. These pages are basically static and rarely need to be rebuilt.Problem
When running
webpack
in watch mode, changes to any file causes all HTML files to be rebuilt, even whenoptions.cache
is set totrue
. This increases the build time from ~500ms to ~3000ms.Cause
The cache check on line 132 of
index.js
is never reached becauseisCompilationCached
always comes back false. This is becausecompilationResult.hash
(line 81) changes on every recompile.Possible fix
I can fix this behavior by removing the check for
isCompilationCached
on line 132.This solves the issue for my needs, but I'm not sure what the implications of making this change are.
Edit: This change causes the "HtmlWebpackPluginCaching should compile the webpack html if the template file was changed" test to fail. This never comes up for my specific use case as the template file does not change, but I'm thinking my use case might be more of a feature request.
Related: #963
Environment
The text was updated successfully, but these errors were encountered: