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

Enable reload on custom logic #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

andreyvolokitin
Copy link

@andreyvolokitin andreyvolokitin commented Mar 15, 2021

Usually page gets reloaded when compilation hash changes, but sometimes it may be desirable to reload even if hash stays the same. I.e. CopyWebpackPlugin can emit changed files, but it doesn't change compilation hash, so the page doesn't reload. In this case you could check emitted files in options callback, to decide if reloading is required:

shouldReload(compilation) {
    return Array.from(compilation.emittedAssets).some(assetName => path.extname(assetName) === '.php');
}

@web-mi
Copy link
Collaborator

web-mi commented Mar 29, 2021

Maybe we could change the logic more globally/configureable.

  1. New option useChildHash (default: true) to disable check for compilation.children hashes.
  2. New option useCompilationHash (default: true) to disable check for compilation hash.

I currently have no time to try it but i think the above two logics are obsolet because we got the function _fileIgnoredOrNotEmitted which is already checking if a file is emitted but to ensure all installations are still working we should add it as optional option first.

For your example maybe its just enough to disable the compilationHash option because your files will exists in compilation.children.

@statianzo or am i wrong or forgot something?

index.js Outdated Show resolved Hide resolved
@@ -152,7 +155,7 @@ class LiveReloadPlugin {
if (
this._isRunning()
&& include.length > 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tested this code and in my case include.length is already 0 since none of the "assets" in the compilation has changed. In my scenario the shouldReload-call should need to "winn" over the include as well.

Co-authored-by: Marc Itzenthaler <[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

Successfully merging this pull request may close these issues.

3 participants