feat: support air reload

This commit is contained in:
engigu
2026-02-10 14:35:10 +08:00
parent 937ad40ea0
commit 1845002f9d
3 changed files with 58 additions and 6 deletions
+44
View File
@@ -0,0 +1,44 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "bin"
[build]
args_bin = []
bin = "./bin/baihu"
cmd = ":"
full_bin = "go run main.go"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata", "web", "data", "envs", "configs", "bin"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = true
[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"
[log]
main_only = false
time = false
[misc]
clean_on_exit = false
[screen]
clear_on_rebuild = false
keep_scroll = true
+4 -1
View File
@@ -48,4 +48,7 @@ configs/config.local.json
__pycache__/
# Misc
.stfolder
.stfolder
bin/
+10 -5
View File
@@ -1,5 +1,5 @@
# Variables
BINARY=baihu
BINARY=bin/baihu
GOBUILD=go build
GOCLEAN=go clean
GOGET=go get
@@ -19,6 +19,7 @@ build-web:
# Build the application (requires frontend to be built first)
build:
@mkdir -p bin
CGO_ENABLED=0 $(GOBUILD) $(LDFLAGS) -o $(BINARY) main.go
# Build all (frontend + backend)
@@ -59,20 +60,24 @@ build-agent-darwin-arm64:
# Clean built files
clean:
$(GOCLEAN)
rm -f $(BINARY)
rm -rf bin/
rm -rf internal/static/dist
mkdir -p internal/static/dist
touch internal/static/dist/.gitkeep
# Run the application
run:
@mkdir -p bin
$(GOBUILD) -o $(BINARY) main.go
./$(BINARY)
# Development run (without embedding frontend)
# Development run with hot reload (both frontend and backend)
dev:
$(GOBUILD) -o $(BINARY) main.go
./$(BINARY)
@command -v air > /dev/null 2>&1 || go install github.com/air-verse/air@latest
@command -v concurrently > /dev/null 2>&1 || npm install -g concurrently
concurrently --kill-others \
"air" \
"cd web && npm run dev"
# Install dependencies
deps: