]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
commands: Fix flaw in the livereload logic
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 25 Nov 2024 09:39:17 +0000 (10:39 +0100)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 25 Nov 2024 09:39:17 +0000 (10:39 +0100)
I guess most commonly an issue with TailwindCSS editing in templates:

* Build changes both CSS and index.html => reload OK.
* Build changes both CSS and index.html and some other files => only CSS reloaded.

The above would fix itself with one more edit, but that's annoying.

commands/hugobuilder.go

index 95129018f1ae5304ddff0d7237bc9240b5d94349..51493938d105df00ed055cc01ba4dbcb00a0dbd4 100644 (file)
@@ -966,7 +966,7 @@ func (c *hugoBuilder) handleEvents(watcher *watcher.Batcher,
                                        pathToRefresh := h.PathSpec.RelURL(paths.ToSlashTrimLeading(otherChanges[0]), false)
                                        lrl.Logf("refreshing %q", pathToRefresh)
                                        livereload.RefreshPath(pathToRefresh)
-                               } else if len(cssChanges) == 0 {
+                               } else if len(cssChanges) == 0 || len(otherChanges) > 1 {
                                        lrl.Logf("force refresh")
                                        livereload.ForceRefresh()
                                }