diff --git a/Makefile b/Makefile index 43d0824..bd4796f 100644 --- a/Makefile +++ b/Makefile @@ -9,3 +9,15 @@ clean: archive: tar -cvf ./dist.tar ./dist + +dev: install build-render + go run devserver/main.go & + reflex --config=devserver.reflex --decoration=fancy + +build-render: build + ./renderblog -f=1 + +install: +ifeq (, $(shell which reflex)) + go install github.com/cespare/reflex@latest +endif diff --git a/devserver.reflex b/devserver.reflex new file mode 100644 index 0000000..a266ca4 --- /dev/null +++ b/devserver.reflex @@ -0,0 +1,11 @@ +# Re-render blog +-R '^dist/' -r '^_site/.*' -- \ + ./renderblog + +# Rebuild binary +-R '^dist/' -r '\.go$' -- \ + make build-render + +# Rerun tailwind when templates or tailwind config change +-R '^dist/' -r '\.html\.tmpl$|tailwind\.config\.js$' -- \ + ./renderblog -f=1 diff --git a/devserver/main.go b/devserver/main.go index 7905807..c04defb 100644 --- a/devserver/main.go +++ b/devserver/main.go @@ -1,5 +1,11 @@ package main -func main() { +import "net/http" +func main() { + dist := http.FileServer(http.Dir("dist")) + err := http.ListenAndServe("localhost:8080", dist) + if err != nil { + panic(err) + } }