feat(build): integrate frontend build into backend binary and update scripts
Build / ubuntu-latest (push) Canceled after 16s
Build / windows-latest (push) Canceled after 24s

This commit is contained in:
2026-09-22 22:57:08 +08:00
parent df2c7a6f92
commit cc4aebde6a
15 changed files with 175 additions and 109 deletions
-1
View File
@@ -1,4 +1,3 @@
node_modules/
dist/
*.local
.DS_Store
+3 -3
View File
@@ -24,14 +24,14 @@ The dev server proxies `/api` (and the log websocket) to the backend. By default
$env:NUKUMIZU_API = "http://192.168.20.4:8080"; npm run dev
```
Production build (static assets only):
Production build:
```bash
npm run build # outputs dist/
npm run build # outputs ../web/dist
npm run preview
```
The backend does not serve static files, so put `dist/` behind any static server and proxy `/api` (and `ws://…/api/system/getLogs`) to the Nukumizu backend.
Vite writes to `../web/dist` rather than `frontend/dist` (see `build.outDir` in `vite.config.js`) because the Go backend embeds that directory into the binary — `go:embed` cannot reach outside the package it sits in, so the output has to live under `web/`. The repo's `build-*` scripts run this build for you and compile the backend afterwards; `npm run build` alone does not change what an already-built binary serves.
## API contract notes
+10
View File
@@ -6,6 +6,16 @@ const BACKEND = process.env.NUKUMIZU_API || 'http://127.0.0.1:8080';
export default defineConfig({
plugins: [vue()],
build: {
// web/embed.go embeds this directory into the Go binary. It has to live
// inside the web package: go:embed cannot reach outside its own
// directory, so ../web/dist is as close as it gets.
outDir: '../web/dist',
// The directory is outside the project root, so Vite refuses to empty
// it unless told to. Without this, stale hashed assets from earlier
// builds pile up in the binary.
emptyOutDir: true
},
server: {
host: '0.0.0.0',
port: 5173,