Add hot-reload support with air for Go backend

- Add .air.toml configuration for Go hot-reloading
- Add 'dev' target to run both frontend and backend together
- Update dev-backend to use air instead of go run
- Install air with: go install github.com/air-verse/air@latest
This commit is contained in:
Christoph Haas 2026-03-23 21:40:40 +01:00
parent 44dea14885
commit ad159b2549
2 changed files with 26 additions and 4 deletions

View file

@ -1,4 +1,4 @@
.PHONY: all dev-frontend dev-backend build build-frontend build-backend clean test lint
.PHONY: all dev dev-frontend dev-backend build build-frontend build-backend clean test lint
# Variables
APP_NAME := imc-vibe
@ -30,13 +30,16 @@ build-backend: build-frontend
@echo "Backend built successfully"
# Development targets
dev: dev-frontend dev-backend
@echo "Development mode running..."
dev-frontend:
@echo "Starting frontend dev server..."
cd $(FRONTEND_DIR) && bun run dev
dev-backend:
@echo "Starting backend dev server..."
cd $(BACKEND_DIR) && USE_EMBEDDED=false go run ./cmd/server
@echo "Starting backend dev server (hot-reload enabled)..."
cd $(BACKEND_DIR) && USE_EMBEDDED=false air
# Clean build artifacts
clean:
@ -63,8 +66,9 @@ help:
@echo " build - Build frontend and backend"
@echo " build-frontend - Build frontend only"
@echo " build-backend - Build backend only"
@echo " dev - Start both frontend and backend with hot-reload"
@echo " dev-frontend - Start frontend dev server"
@echo " dev-backend - Start backend dev server"
@echo " dev-backend - Start backend dev server (requires: go install github.com/air-verse/air@latest)"
@echo " clean - Remove build artifacts"
@echo " test - Run backend tests"
@echo " lint - Run Go vet"

18
backend/.air.toml Normal file
View file

@ -0,0 +1,18 @@
# .air.toml - Air configuration for hot-reloading Go backend
# Install air: go install github.com/air-verse/air@latest
[root]
temp_dir = "tmp"
watch_dirs = ["."]
ignore_dirs = ["tmp", "vendor", "cmd/server/embed"]
[build]
bin = "./tmp/imc-vibe"
cmd = "go build -o ./tmp/imc-vibe ./cmd/server"
stop_on_error = true
[log]
main_only = true
[misc]
clean_on_exit = true