dev: add workspace web hot reload setup

This commit is contained in:
Keisuke Hirata 2026-06-22 01:06:37 +09:00
parent de1a20c007
commit dfbfd6ed82
No known key found for this signature in database
4 changed files with 71 additions and 22 deletions

1
.yoi/.gitignore vendored
View File

@ -1,2 +1,3 @@
/memory/ /memory/
tickets/.ticket-backend.lock tickets/.ticket-backend.lock
/workspace.db*

View File

@ -1,30 +1,69 @@
# Workspace web SPA # Workspace web UI
This is the static SvelteKit shell for the local Yoi Workspace control plane. SvelteKit static SPA for the Yoi workspace control plane.
It is intentionally a read-only UI bootstrap: `.yoi/tickets` and
`.yoi/objectives` remain canonical, and the Rust backend owns all business/API
semantics.
Canonical frontend tooling: Deno. Dependency versions, tasks, and the committed The frontend is intentionally static. Workspace authority, validation, and API behavior live in the Rust `yoi-workspace-server` backend.
lockfile are managed by `deno.json` and `deno.lock`.
`package.json` is intentionally kept only as minimal SvelteKit/Vite ecosystem ## Development
metadata (`type: module`, private package identity). It does not define scripts
or dependencies and is not the package-manager source of truth.
Commands: Use two terminals from the repository checkout.
```sh Backend terminal:
deno install
deno task check ```bash
cd web/workspace
deno task dev:backend
```
Frontend terminal:
```bash
cd web/workspace
deno task dev
```
The Vite dev server proxies `/api/*` to `http://127.0.0.1:8787`, so frontend hot reload works while the Rust backend serves the workspace API. Open the Vite URL printed by `deno task dev`.
If you want to run the backend from the repository root instead:
```bash
cargo run -p yoi-workspace-server -- serve \
--workspace . \
--db .yoi/workspace.db \
--listen 127.0.0.1:8787
```
## Static build served by Rust backend
Build the SPA:
```bash
deno task build deno task build
``` ```
`deno task dev` and `deno task preview` are available for local frontend work. Then serve the static build and API from the Rust backend:
Deno uses npm compatibility for the SvelteKit/Vite toolchain, so `node_modules/`
may be created as generated local state; do not check it in.
Build output is `web/workspace/build/` and is not checked in. Point the Rust ```bash
backend `ServerConfig.static_assets_dir` at that directory (or another static cargo run -p yoi-workspace-server -- serve \
asset directory) to serve the SPA. `node_modules/`, `.svelte-kit/`, and `build/` --workspace ../.. \
are generated local state and must remain ignored/excluded from package sources. --db ../../.yoi/workspace.db \
--frontend build \
--listen 127.0.0.1:8787
```
From the repository root, the equivalent command is:
```bash
cargo run -p yoi-workspace-server -- serve \
--workspace . \
--db .yoi/workspace.db \
--frontend web/workspace/build \
--listen 127.0.0.1:8787
```
## Checks
```bash
deno task check
deno task build
```

View File

@ -4,6 +4,7 @@
"tasks": { "tasks": {
"install": "deno install", "install": "deno install",
"dev": "deno run -A npm:vite@7.2.7 dev", "dev": "deno run -A npm:vite@7.2.7 dev",
"dev:backend": "cd ../.. && cargo run -p yoi-workspace-server -- serve --workspace . --db .yoi/workspace.db --listen 127.0.0.1:8787",
"check": "deno run -A npm:@sveltejs/kit@2.49.4 sync && deno run -A npm:svelte-check@4.3.4 --tsconfig ./tsconfig.json", "check": "deno run -A npm:@sveltejs/kit@2.49.4 sync && deno run -A npm:svelte-check@4.3.4 --tsconfig ./tsconfig.json",
"build": "deno run -A npm:vite@7.2.7 build", "build": "deno run -A npm:vite@7.2.7 build",
"preview": "deno run -A npm:vite@7.2.7 preview" "preview": "deno run -A npm:vite@7.2.7 preview"

View File

@ -2,5 +2,13 @@ import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite'; import { defineConfig } from 'vite';
export default defineConfig({ export default defineConfig({
plugins: [sveltekit()] plugins: [sveltekit()],
server: {
proxy: {
'/api': {
target: 'http://127.0.0.1:8787',
changeOrigin: true
}
}
}
}); });