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
+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: