Inject the reload scriipt into the head if injectLiveReload is set.

This commit is contained in:
2025-03-04 20:50:21 +01:00
parent 4b0bfa8e4c
commit a3cebd2b3e
9 changed files with 260 additions and 144 deletions

View File

@ -21,6 +21,14 @@ func watchAction(ctx *cli.Context) error {
os.Chdir(filepath.Dir(cfgPath))
optsSetups := readCfg(cfgPath)
pipeline := func(opts options) {
purge(opts)
cp(opts)
build(opts)
injectLR(opts)
replace(opts)
}
for i := range optsSetups {
opts := optsSetups[i]
@ -49,10 +57,7 @@ func watchAction(ctx *cli.Context) error {
select {
case event := <-w.Event:
fmt.Printf("File %s changed\n", event.Name())
purge(opts)
cp(opts)
build(opts)
replace(opts)
pipeline(opts)
case err := <-w.Error:
fmt.Println(err.Error())
case <-w.Closed:
@ -63,10 +68,7 @@ func watchAction(ctx *cli.Context) error {
fmt.Printf("Watching %d elements in %s\n", len(w.WatchedFiles()), opts.Watch.Paths)
purge(opts)
cp(opts)
build(opts)
replace(opts)
pipeline(opts)
if err := w.Start(time.Millisecond * 100); err != nil {
fmt.Println(err.Error())