Timestamp based check for changes to HTML template #965
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As of webpack version 4,
isCompilationCached
no longer appears to be a reliable method of checking whether a template file has been changed. Instead, we can checkcompilation.fileTimestamps
to see when the template file was last modified.For a 25 html page project, I've found this change reduces the rebuild time from ~3000ms to ~700ms in
--watch
mode.NOTE: this commit fails the build test because
WebpackRecompilationSimulator.simulateFileChange
does not change thecompilation.fileTimestamps
object.One way to solve this might be to have
simulateFileChange
write to the source file and then immediately revert the changes. Another might be to initialize theHtmlWebpackPlugin
with the temp file as the template instead of the source file. Both require making changes to webpack-recompilation-simulator, which I'm not sure how to build.In practice, I've found this commit to work as expected with
webpack --watch
.