/ listening-for-chaos / chaos-apps
Sign in
listening-for-chaos / chaos-apps
chaos-apps / vite.config.ts
28 lines · 1.0 KBBlameHistoryRaw
1import { defineConfig } from "vite";
3// One multi-page site: src/index.html (landing page) and one page per app in
4// src/<app>/index.html, served at /<app>/. Shared code goes in src/common/.
5// Relative asset paths, so the build works wherever the site is served
6// (an origin root or a /<collection>/<repo>/site/ path); ES module workers.
7const page = (p: string) => decodeURIComponent(new URL(`./src/${p}`, import.meta.url).pathname);
9export default defineConfig({
10 root: "src",
11 base: "./",
12 worker: { format: "es" },
13 build: {
14 outDir: "../dist",
15 emptyOutDir: true,
16 rolldownOptions: {
17 input: {
18 main: page("index.html"),
19 "double-pendulum": page("double-pendulum/index.html"),
20 "fput-chain": page("fput-chain/index.html"),
21 beam: page("beam/index.html"),
22 },
23 // Name the chunk holding src/common/ "common" (otherwise it takes the
24 // name of one of its modules).
25 output: { manualChunks: (id: string) => (id.includes("/src/common/") ? "common" : undefined) },
26 },
27 },
28});
↑↓ move↵openescclose