more config
This commit is contained in:
parent
da82b7f536
commit
2bac9307c6
6 changed files with 29 additions and 34 deletions
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func IsTailwindEnabled() bool {
|
func IsTailwindEnabled() bool {
|
||||||
return dirutil.HasFileFromRoot("tailwind.config.js")
|
return dirutil.GetConfig().Tailwind && dirutil.HasFileFromRoot("tailwind.config.js")
|
||||||
}
|
}
|
||||||
|
|
||||||
func Setup() bool {
|
func Setup() bool {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/maddalax/htmgo/cli/htmgo/internal"
|
"github.com/maddalax/htmgo/cli/htmgo/internal"
|
||||||
|
|
@ -36,8 +35,6 @@ func startWatcher(cb func(version string, file []*fsnotify.Event)) {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case event, ok := <-watcher.Events:
|
case event, ok := <-watcher.Events:
|
||||||
slog.Debug("event:", slog.String("name", event.Name), slog.String("op", event.Op.String()))
|
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -69,8 +66,10 @@ func startWatcher(cb func(version string, file []*fsnotify.Event)) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if dirutil.IsGlobMatch(event.Name, config.WatchFiles, config.WatchIgnore) {
|
|
||||||
if event.Has(fsnotify.Write) || event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename) {
|
if event.Has(fsnotify.Write) || event.Has(fsnotify.Remove) || event.Has(fsnotify.Rename) {
|
||||||
|
if !dirutil.IsGlobMatch(event.Name, config.WatchFiles, config.WatchIgnore) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
events = append(events, &event)
|
events = append(events, &event)
|
||||||
debouncer.Do(func() {
|
debouncer.Do(func() {
|
||||||
seen := make(map[string]bool)
|
seen := make(map[string]bool)
|
||||||
|
|
@ -85,7 +84,7 @@ func startWatcher(cb func(version string, file []*fsnotify.Event)) {
|
||||||
events = make([]*fsnotify.Event, 0)
|
events = make([]*fsnotify.Event, 0)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
|
||||||
case err, ok := <-watcher.Errors:
|
case err, ok := <-watcher.Errors:
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
|
|
@ -105,15 +104,6 @@ func startWatcher(cb func(version string, file []*fsnotify.Event)) {
|
||||||
watcher.Add(assetPath)
|
watcher.Add(assetPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
time.Sleep(time.Second * 5)
|
|
||||||
files := watcher.WatchList()
|
|
||||||
count := len(files)
|
|
||||||
fmt.Printf("Watching %d dirs\n", count)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Walk through the root directory and add all subdirectories to the watcher
|
// Walk through the root directory and add all subdirectories to the watcher
|
||||||
err = filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error {
|
err = filepath.Walk(rootDir, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
tailwind: true
|
|
||||||
|
|
@ -19,7 +19,7 @@ func DefaultProjectConfig() *ProjectConfig {
|
||||||
"node_modules", ".git", ".idea", "assets/dist",
|
"node_modules", ".git", ".idea", "assets/dist",
|
||||||
},
|
},
|
||||||
WatchFiles: []string{
|
WatchFiles: []string{
|
||||||
"**/*.go", "**/*.html", "**/*.css", "**/*.js", "**/*.json", "**/*.yaml", "**/*.yml",
|
"**/*.go", "**/*.html", "**/*.css", "**/*.js", "**/*.json", "**/*.yaml", "**/*.yml", "**/*.md",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
|
# htmgo configuration
|
||||||
|
|
||||||
|
# if tailwindcss is enabled, htmgo will automatically compile your tailwind and output it to assets/dist
|
||||||
tailwind: true
|
tailwind: true
|
||||||
# which directories to ignore when watching for changes, supports glob patterns
|
|
||||||
|
# which directories to ignore when watching for changes, supports glob patterns through https://github.com/bmatcuk/doublestar
|
||||||
watch_ignore: [".git", "node_modules", "dist/*"]
|
watch_ignore: [".git", "node_modules", "dist/*"]
|
||||||
# files to watch for changes that are not included by default, supports glob patterns
|
|
||||||
watch_files: ["**/*.go", "**/*.css"]
|
# files to watch for changes, supports glob patterns through https://github.com/bmatcuk/doublestar
|
||||||
|
watch_files: ["**/*.go", "**/*.css", "**/*.md"]
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ func PageWithNav(ctx *h.RequestContext, children ...h.Ren) *h.Element {
|
||||||
h.Fragment(
|
h.Fragment(
|
||||||
partials.NavBar(ctx, partials.NavBarProps{
|
partials.NavBar(ctx, partials.NavBarProps{
|
||||||
Expanded: false,
|
Expanded: false,
|
||||||
|
ShowPreRelease: true,
|
||||||
}),
|
}),
|
||||||
h.Div(
|
h.Div(
|
||||||
children...,
|
children...,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue