refactor: frontend TS migration + Tailwind4/daisyUI5 unify + BUILDPLATFORM docker build
- migrate frontend to TypeScript (vue-tsc strict in build), upgrade all deps to latest (Vite 8, Tailwind 4, daisyUI 5, Pinia 4, vue-router 5) - restructure frontend dirs (api/components/common/layouts/styles/types/views) - drop Element Plus, add daisyUI TagInput; main CSS 490KB->163KB, entry JS 618KB->1.3KB - rewrite Dockerfile(.cn): frontend/backend stages pinned to $BUILDPLATFORM, CGO_ENABLED=0 cross-compile, no QEMU in multi-arch builds; add .dockerignore - local dev: Vite /api proxy + make dev targets; go:embed all:dist with .gitkeep so backend runs without prior frontend build - fix latent bugs: Keys.vue users ref, Settings.vue undefined userStore, Login.vue Ref-as-error display, res.error misuse - add REFACTOR_PLAN.md (phased refactor log)
This commit is contained in:
@@ -16,17 +16,36 @@ LDFlags=" \
|
||||
-X 'main.BuildGoVersion=$(BuildGoVersion)'"
|
||||
|
||||
.PHONY: web
|
||||
# web
|
||||
# 构建前端并放入 Go embed 目录 (cmd/openteam/dist)
|
||||
web:
|
||||
cd frontend && npm install -g pnpm && pnpm build && mv dist ../cmd/openteam/
|
||||
|
||||
cd frontend && (command -v pnpm >/dev/null 2>&1 || npm install -g pnpm) && pnpm install --frozen-lockfile && pnpm build
|
||||
rm -rf cmd/openteam/dist
|
||||
mkdir -p cmd/openteam
|
||||
mv frontend/dist cmd/openteam/dist
|
||||
touch cmd/openteam/dist/.gitkeep
|
||||
|
||||
.PHONY: dev-backend
|
||||
# 本地启动后端 (端口 8080, 数据库 ./db/openteam.db)
|
||||
dev-backend:
|
||||
PORT=8080 go run ./cmd/openteam
|
||||
|
||||
.PHONY: dev-frontend
|
||||
# 本地启动前端 dev server (端口 5173, /api 代理到后端)
|
||||
dev-frontend:
|
||||
cd frontend && pnpm dev
|
||||
|
||||
.PHONY: dev
|
||||
# 并行启动前后端本地开发环境 (Ctrl+C 一起退出)
|
||||
dev:
|
||||
$(MAKE) -j2 dev-backend dev-frontend
|
||||
|
||||
.PHONY: build
|
||||
# build
|
||||
build:
|
||||
# mkdir -p bin/ && go build -ldflags $(LDFlags) -o ./bin/ ./...
|
||||
rm -rf bin
|
||||
mkdir -p bin/ && go build -ldflags "-s -w" -o ./bin/openteam ./cmd/openteam/
|
||||
upx -9 bin/openteam
|
||||
rm -rf bin
|
||||
mkdir -p bin/ && CGO_ENABLED=0 go build -ldflags "-s -w" -o ./bin/openteam ./cmd/openteam/
|
||||
command -v upx >/dev/null 2>&1 && upx -9 bin/openteam || echo "upx 未安装,跳过二进制压缩"
|
||||
|
||||
.PHONY:image
|
||||
# build docker images
|
||||
|
||||
Reference in New Issue
Block a user