From 6cc76c6767a0d5a72a389e7003b1a393cad33845 Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Sun, 30 Aug 2026 15:33:16 +0800 Subject: [PATCH] chore: add hot reload for development - Makefile: add dev-backend (air) and dev-frontend (vite) targets - backend/.air.toml: air config for Go live reload - .gitignore: exclude backend/tmp/ --- .gitignore | 1 + Makefile | 16 ++++++++++++---- backend/.air.toml | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 backend/.air.toml diff --git a/.gitignore b/.gitignore index d58197f..1d1ad69 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ bin/ +tmp/ test/ demo/ *.log diff --git a/Makefile b/Makefile index 039979c..2f04295 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build run test clean fmt lint frontend +.PHONY: build run test clean fmt lint frontend dev dev-backend dev-frontend BINARY_NAME=openteam BUILD_DIR=bin @@ -18,9 +18,17 @@ frontend: run: build ./$(BUILD_DIR)/$(BINARY_NAME) -# Development run -dev: - cd $(BACKEND_DIR) && go run ./cmd/openteam +# Development: backend + frontend (requires air + pnpm) +dev: dev-backend dev-frontend + +# Go backend with hot reload (requires: go install github.com/air-verse/air@latest) +dev-backend: + @command -v air >/dev/null 2>&1 || { echo "Installing air..."; go install github.com/air-verse/air@latest; } + cd $(BACKEND_DIR) && air -c .air.toml + +# Vue frontend with HMR +dev-frontend: + cd frontend && pnpm dev # Test test: diff --git a/backend/.air.toml b/backend/.air.toml new file mode 100644 index 0000000..f683d2d --- /dev/null +++ b/backend/.air.toml @@ -0,0 +1,38 @@ +# Air configuration for Go hot reload +# Docs: https://github.com/air-verse/air + +root = "." +tmp_dir = "tmp" + +[build] + bin = "./tmp/main" + cmd = "go build -o ./tmp/main ./cmd/openteam" + delay = 1000 + exclude_dir = ["tmp", "vendor", "node_modules", "frontend"] + exclude_file = [] + exclude_regex = ["_test.go", ".*_test.go"] + exclude_unchanged = false + follow_symlink = false + include_dir = [] + include_ext = ["go", "tpl", "tmpl", "html", "sql"] + kill_delay = "0s" + log = "build-errors.log" + send_interrupt = false + stop_on_error = true + +[color] + 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