-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
37 lines (34 loc) · 1.62 KB
/
Copy pathvite.config.ts
File metadata and controls
37 lines (34 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { defineConfig } from 'vite';
import { fileURLToPath } from 'node:url';
import { contentPlugin } from './src/build/content-plugin';
import { writeAppPages, appPageInputs } from './src/build/app-pages';
// One page model (pages/docs/engine/architecture.md §3): every page is
// markdown under `pages/`, and its file path is its URL (`pages/index.md` → `/`,
// `pages/docs/scumm/room.md` → `/docs/scumm/room/`). Pages with a
// `script:` are *app* pages — the generator stages a real HTML entry + entry.ts
// under `.generated/` (gitignored) so Vite bundles the island; pages without one
// are static content emitted by `contentPlugin`. Both land in a single `dist/`
// over disjoint routes — refresh-safe, crawler-indexable, no server. App game
// ids still ride in `?game=` (client-only).
const entry = (path: string): string => fileURLToPath(new URL(path, import.meta.url));
const pagesDir = entry('./pages');
const stagingRoot = entry('./.generated');
// Stage the app-page entries now so they exist as Vite inputs (build) and are
// served by `root` (dev). contentPlugin re-stages on edits during dev.
writeAppPages(pagesDir, stagingRoot);
export default defineConfig({
root: stagingRoot,
plugins: [contentPlugin({ pagesDir, siteCssPath: entry('./src/site/site.css'), stagingRoot })],
server: {
port: 5173,
},
build: {
// `outDir` sits outside `root`, so `emptyOutDir` is required. Content pages
// are appended by contentPlugin's closeBundle after this app build is written.
outDir: entry('./dist'),
emptyOutDir: true,
rollupOptions: {
input: appPageInputs(pagesDir, stagingRoot),
},
},
});