You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/architecture/frontend-build.md
+36-7Lines changed: 36 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,9 @@ This document explains how the frontend codebase is built, what libraries are in
4
4
5
5
## Overview
6
6
7
-
The frontend is a Svelte single-page application bundled with Rollup. It uses TypeScript for type safety, Tailwind CSS v4 for styling, and a generated SDK for type-safe API calls. The build outputs static files to `public/build/` which are served by nginx in production or by a custom HTTPS dev server during development.
7
+
The frontend is a Svelte 5 single-page application bundled with Rollup. It uses TypeScript for type safety, Tailwind CSS v4 for styling, and a generated SDK for type-safe API calls. The build outputs static files to `public/build/` which are served by nginx in production or by a custom HTTPS dev server during development.
8
+
9
+
For details on the Svelte 5 runes API and migration patterns, see [Svelte 5 Migration](svelte5-migration.md).
8
10
9
11
```mermaid
10
12
graph LR
@@ -46,14 +48,15 @@ The `rollup.config.js` file configures the entire build pipeline. It produces ES
46
48
47
49
### Entry point
48
50
49
-
The build starts from `src/main.ts`, which imports the API client setup, mounts the Svelte `App` component, and imports global CSS:
51
+
The build starts from `src/main.ts`, which imports the API client setup, mounts the Svelte `App` component using Svelte 5's `mount()` function, and imports global CSS:
50
52
51
53
```typescript
54
+
import { mount } from'svelte';
52
55
import'./lib/api/setup';
53
56
importAppfrom'./App.svelte';
54
57
import'./app.css';
55
58
56
-
const app =newApp({
59
+
const app =mount(App, {
57
60
target: document.body,
58
61
});
59
62
```
@@ -64,7 +67,7 @@ Rollup splits the bundle into chunks to improve load performance. The `manualChu
64
67
65
68
| Chunk | Contents |
66
69
|-------|----------|
67
-
|`vendor`| Svelte, svelte-routing, axios|
70
+
|`vendor`| Svelte, @mateothegreat/svelte5-router|
68
71
|`codemirror`| All CodeMirror packages for the editor |
69
72
| Application chunks | Route components and shared code |
70
73
@@ -75,7 +78,7 @@ This means users don't re-download vendor code when application code changes, an
75
78
The plugin pipeline processes files in order:
76
79
77
80
1.**replace** — Substitutes `process.env.VITE_BACKEND_URL` with an empty string, allowing relative API paths
78
-
2.**svelte** — Compiles `.svelte` files with TypeScript preprocessing via `svelte-preprocess`
81
+
2.**svelte** — Compiles `.svelte` files with TypeScript preprocessing via `svelte-preprocess`, with `runes: true` enabled for Svelte 5
79
82
3.**postcss** — Processes CSS through PostCSS, extracting styles to `bundle.css`
80
83
4.**typescript** — Compiles TypeScript files with source maps
81
84
5.**json** — Allows importing JSON files
@@ -237,9 +240,11 @@ Styles are organized into Tailwind layers:
237
240
- **base** — Element defaults, form styles, scrollbars, CodeMirror overrides
238
241
- **components** — Reusable patterns like `.btn`, `.card`, `.form-input-standard`
239
242
240
-
## Svelte stores
243
+
## Svelte stores and runes
244
+
245
+
The frontend uses a hybrid approach to state management:
241
246
242
-
Reactive state is managed through Svelte stores in `src/stores/`:
@@ -250,6 +255,30 @@ Reactive state is managed through Svelte stores in `src/stores/`:
250
255
251
256
Stores use the generated SDK for API calls and persist state to localStorage where appropriate. The auth store exposes a `csrfToken` store that the API client interceptor reads for request signing.
0 commit comments