/ listening-for-chaos / chaos-apps
Sign in
listening-for-chaos / chaos-apps
chaos-apps / vite.config.ts
27 lines · 1014 BCodeBlameHistory
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 },
420fab0Shared styles in src/common/style.css; each app's own rules in its style.css, imported afterJeremy Magland 22 // Name the chunk holding src/common/ "common" (otherwise it takes the
23 // name of one of its modules).
24 output: { manualChunks: (id: string) => (id.includes("/src/common/") ? "common" : undefined) },
26 },
27});
↑↓ move↵openescclose