build: add one-command dev launcher

scripts/dev.sh checks toolchains and ports, installs frontend deps when
the lockfile changes, starts the Go server and Vite with prefixed logs,
and stops both on Ctrl+C or when either exits. The Vite proxy reads the
same API_PORT so custom ports keep working.
This commit is contained in:
eezd committed 2026-10-16 18:48:58 +08:00
1 parent dc7e43bc3c
commit b3f05b501a
3 files changed
+99 -9

No files matched your search

+4 -7
View File
@@ -28,17 +28,14 @@ docker run -d --name rawmark \
## 开发
需要 Go 1.27+ 与 Node 24+。开发时不必构建前端或 Docker 镜像,开两个终端:
需要 Go 1.27+ 与 Node 24+。开发时不必构建前端或 Docker 镜像,一键启动:
```sh
# 终端 1:后端(-tags dev 不嵌入前端资源,数据放在仓库下的 .dev-data/)
RAWMARK_DATA=.dev-data RAWMARK_ADDR=127.0.0.1:8080 go run -tags dev ./cmd/rawmark
# 终端 2:前端(热更新,/api 与 WebSocket 转发到 127.0.0.1:8080)
cd web && npm install && npm run dev
scripts/dev.sh # 后端 go run -tags dev + 前端 Vite 热更新,Ctrl+C 同时退出
scripts/dev.sh --host # 前端监听所有网卡,手机访问 http://<电脑 IP>:5173
```
浏览器打开 http://localhost:5173 ,启动码在 `.dev-data/setup-code.txt`。手机调试用 `npm run dev -- --host`,再访问 `http://<电脑 IP>:5173`。
浏览器打开 http://localhost:5173 ,启动码在 `.dev-data/setup-code.txt`。端口与数据目录可用 `API_PORT`、`WEB_PORT`、`RAWMARK_DATA` 覆盖,详见 `scripts/dev.sh --help`。
检查: