Skip to content

Commit

Permalink
chore: add dev server and auto reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
sewera committed Nov 20, 2023
1 parent 557edf9 commit 6d20492
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions devserver.reflex
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion devserver/main.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 6d20492

Please sign in to comment.