build: 保留 go:embed 占位页,新克隆无需 node 即可编译
go:embed 要求目标目录存在才能编译,而构建产物不进版本库 —— 上一版把整个 gateway/internal/static/static/ 忽略掉,导致新克隆连 go build ./cmd/server 都跑不起来(pattern static: no matching files found), 只改后端的人被迫先装 node。 改为忽略目录内容但保留一个占位 index.html:说明前端未构建、给出构建命令, 并明确后端 API 仍然可用。真实产物由 install.sh 覆盖后嵌入。
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@ -9,9 +9,12 @@ web/dist/
|
||||
plugins/*/node_modules/
|
||||
|
||||
# go:embed 的输入目录 = web/dist 的副本,同属构建产物。
|
||||
# 注意 embed 要求目录存在才能编译,克隆后需先跑一次
|
||||
# `deploy/install.sh`(或 npm run build && cp -r web/dist ...)。
|
||||
gateway/internal/static/static/
|
||||
#
|
||||
# 但目录本身要留下:go:embed 要求它存在才能编译,否则新克隆连
|
||||
# `go test ./...` 都跑不起来 —— 只改后端的人不该被迫先装 node。
|
||||
# 因此忽略里面的产物,只保留一个占位 index.html(见该文件内注释)。
|
||||
gateway/internal/static/static/*
|
||||
!gateway/internal/static/static/index.html
|
||||
|
||||
# Go 构建产物
|
||||
gateway/agentmail-gateway
|
||||
|
||||
69
gateway/internal/static/static/index.html
Normal file
69
gateway/internal/static/static/index.html
Normal file
@ -0,0 +1,69 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
占位页。
|
||||
|
||||
真实前端由 `deploy/install.sh`(或 npm run build + cp -r web/dist)
|
||||
覆盖本目录后经 go:embed 打进二进制。
|
||||
|
||||
这个文件之所以要提交进版本库:go:embed 要求目标目录存在才能编译,
|
||||
否则新克隆连 go test ./... 都跑不起来 —— 只改后端的人不该被迫先装 node。
|
||||
|
||||
看到本页说明二进制里没有前端产物,后端 API 仍然可用。
|
||||
-->
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>AgentMail — 前端未构建</title>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: #f1f5f9;
|
||||
color: #334155;
|
||||
font: 14px/1.7 system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
}
|
||||
main { max-width: 34rem; padding: 2rem; }
|
||||
h1 { font-size: 1rem; margin: 0 0 0.75rem; }
|
||||
code {
|
||||
background: #e2e8f0;
|
||||
padding: 0.1rem 0.35rem;
|
||||
border-radius: 3px;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
pre {
|
||||
background: #fff;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 6px;
|
||||
padding: 0.75rem 1rem;
|
||||
overflow-x: auto;
|
||||
font-size: 0.85em;
|
||||
}
|
||||
p { margin: 0 0 0.75rem; }
|
||||
.dim { color: #64748b; font-size: 0.9em; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>AgentMail 前端未构建</h1>
|
||||
<p>
|
||||
当前二进制里嵌入的是占位页。后端 API 仍然可用(<code>/api/v1</code>、
|
||||
<code>/health</code>)。
|
||||
</p>
|
||||
<p>构建并嵌入前端:</p>
|
||||
<pre>sudo ./deploy/install.sh</pre>
|
||||
<p>或者手工:</p>
|
||||
<pre>cd web && npm ci && npm run build
|
||||
rm -rf ../gateway/internal/static/static
|
||||
cp -r dist ../gateway/internal/static/static
|
||||
cd ../gateway && go build ./cmd/server</pre>
|
||||
<p class="dim">
|
||||
构建产物不进版本库;这个占位文件的存在只是为了让
|
||||
<code>go:embed</code> 在新克隆里能编译通过。
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user