feat(build): integrate frontend build into backend binary and update scripts
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
node_modules/
|
||||
dist/
|
||||
*.local
|
||||
.DS_Store
|
||||
|
||||
+3
-3
@@ -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
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user