import { defineConfig } from "vite"; // One multi-page site: src/index.html (landing page) and one page per app in // src//index.html, served at //. Shared code goes in src/common/. // Relative asset paths, so the build works wherever the site is served // (an origin root or a ///site/ path); ES module workers. const page = (p: string) => decodeURIComponent(new URL(`./src/${p}`, import.meta.url).pathname); export default defineConfig({ root: "src", base: "./", worker: { format: "es" }, build: { outDir: "../dist", emptyOutDir: true, rolldownOptions: { input: { main: page("index.html"), "double-pendulum": page("double-pendulum/index.html"), "fput-chain": page("fput-chain/index.html"), beam: page("beam/index.html"), plate: page("plate/index.html"), }, // Name the chunk holding src/common/ "common" (otherwise it takes the // name of one of its modules). output: { manualChunks: (id: string) => (id.includes("/src/common/") ? "common" : undefined) }, }, }, });