Files
yellowjacket/frontend/vite.config.mts
T
logan 795f40acee perf(frontend): split the routes and warm the chunks on idle
One 1.18 MB chunk containing all 27 views, every one eagerly imported
and side-effect-evaluated before first paint. `index.ts` now holds a
loader table per view and awaits the right chunk before creating the
element. JS evaluated before first paint: 1 480 kB -> 772.9 kB, in 27
chunks instead of one, with the slowest first open of a view at 19 ms
against 21 ms — both halves of the trade, and the second did not get
worse.

Two things it has to get right. `document.createElement` on an
undefined tag yields an inert HTMLElement rather than throwing, so a
missing entry in the table is a blank page and not an error; and
navigations are numbered, so a slow chunk cannot land on top of a
faster navigation. `notification-host`, `inline-notice` and
`confirm-dialog` stay eager on purpose: a failure surface that has to
fetch a chunk before it can speak is not a failure surface, and the
moment it is most needed is the likeliest moment loading one fails.
2026-08-12 01:19:04 -04:00

38 lines
1.3 KiB
TypeScript

import path from "path";
import { defineConfig } from "vite";
export default defineConfig({
resolve: {
alias: {
"@go": path.resolve(__dirname, "wailsjs/go"),
"@components": path.resolve(__dirname, "src/components"),
"@assets": path.resolve(__dirname, "src/assets"),
"@pages": path.resolve(__dirname, "src/pages"),
"@runtime": path.resolve(__dirname, "wailsjs/runtime"),
"@utils": path.resolve(__dirname, "src/utils"),
"@store": path.resolve(__dirname, "src/store"),
},
},
build: {
// The bundled icons must be emitted as files, not inlined.
// Vite inlines any asset under 4 kB, and 63 of the 64 icons are
// under 4 kB, so the default put ~96 kB of base64 into the main
// chunk — parsed at startup, for icons most views never render.
// As files they are served same-origin (so still offline) and
// fetched on first use.
assetsInlineLimit: (filePath: string) =>
filePath.includes('/assets/icons/fa/') ? false : undefined,
rollupOptions: {
input: {
main: "index.html",
},
},
},
server: {
hmr: {
host: 'localhost',
protocol: 'ws',
},
},
});