2f32186d22
The markdown parser was in the eager entry chunk. `manualChunks` in its object form does not leave an unlisted vendor package to Vite's async splitting, so react-markdown was hoisted into the entry even though its only importers are lazy routes — 327.70 kB gzip against a 314 kB baseline, on the one download every route pays for. Naming it as its own chunk puts it back behind the Motion pages and takes the entry to 282.21 kB, below where it was before Motion existed. The starter library could never be improved. Seeding was insert-only, so a deployment seeded in August was frozen on August's wording for ever with no upgrade path short of editing production rows by hand — for a feature whose entire premise is that the library gets better. A second run now refreshes a starter row, but only while it is still ours: `is_system`, `usage_count = 0` and no owner. That is the same condition §7a already enforces on the API, so a template an engagement was cut from is left alone and reported by name rather than silently overwritten. The refresh was not idempotent, and the seed lied about it. `jsonb` does not preserve key order — Postgres sorts keys by length then bytewise — so comparing `JSON.stringify(stored)` against `JSON.stringify(authored)` marked every template as changed on every run, and the seed rewrote nine rows each time while reporting itself clean. Comparison is now canonical. Found by running the seed three times and reading the counts. `motion-overflow-check.mjs` measured less than it claimed. It seeded `pig.sidebar` and `pig.piggy.dock`, neither of which anything reads (the keys are `pig.sidebarOpen` and `pig.piggyDockOpen`), so the layout it pinned was whatever the last run left. Its dark pass set `colorScheme` only, and the appearance preference is stored server-side and adopted after hydration, so the dark pass measured the light palette a beat after first paint. It now rewrites the profile response as `screenshots.mjs` does, asserts the rendered `data-theme`, and fails a page that renders almost no text — a page that throws inside its own body otherwise measures zero overflow and passes. The stage rail rendered "1 templates", in the visible label and in every aria-label. Singular and plural are now both passed. Also normalised `artifact` to `artefact` in the seeded prose, which had drifted American in the playbook. The `artifacts` field key is untouched: FieldsView reads it, and already labels it in British.
60 lines
2.4 KiB
TypeScript
60 lines
2.4 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { fileURLToPath, URL } from 'node:url';
|
|
|
|
const apiTarget = process.env.PIG_API_TARGET ?? 'http://localhost:8920';
|
|
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) },
|
|
},
|
|
server: {
|
|
// Both are overridable so a second checkout (a worktree, a review branch)
|
|
// can run its own API and web server without colliding with the first.
|
|
port: Number(process.env.PIG_WEB_PORT ?? 5173),
|
|
// Proxy in development so the browser sees one origin, matching how
|
|
// production serves the API and the app together. Auth sessions are
|
|
// per-origin, so a split origin in dev but not prod hides real bugs.
|
|
/*
|
|
* `/media` is proxied as well as `/api`, because Learn videos PIG hosts
|
|
* itself are served from the API on a non-/api path. Without this entry
|
|
* Vite answers the <video> request with index.html and the player shows a
|
|
* black box with working controls and no error — the same silent
|
|
* 200-text/html failure the API guards against for its own routes.
|
|
*/
|
|
proxy: {
|
|
'/api': { target: apiTarget, changeOrigin: true },
|
|
'/media': { target: apiTarget, changeOrigin: true },
|
|
},
|
|
},
|
|
build: {
|
|
outDir: 'dist',
|
|
sourcemap: true,
|
|
rollupOptions: {
|
|
output: {
|
|
/*
|
|
* Split the vendor code that changes rarely from the app code that
|
|
* changes constantly, so a deploy invalidates only the small chunk.
|
|
* This matters on mobile: the auth client alone is a large download,
|
|
* and re-fetching it on every deploy over a cellular connection is
|
|
* exactly the cost worth avoiding.
|
|
*/
|
|
manualChunks: {
|
|
react: ['react', 'react-dom', 'react-router-dom'],
|
|
supabase: ['@supabase/supabase-js'],
|
|
query: ['@tanstack/react-query'],
|
|
/*
|
|
* Named explicitly, or the object form of `manualChunks` hoists the
|
|
* markdown parser into the entry chunk even though the only importers
|
|
* are lazy routes — measured at 327.70 kB gzip entry with it hoisted
|
|
* against 314 kB without. As its own chunk it is fetched when a
|
|
* Motion page is opened and never on any other route.
|
|
*/
|
|
markdown: ['react-markdown', 'remark-gfm'],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|