Two corrections, and the first was a bug I had just written. `vercel.json` served `/viewer.js` and `/viewer.css` with a year of immutable caching, and those names carry no content hash — they are pinned in the vite config. Immutable caching on a fixed name means a returning visitor is handed the bundle they already have, for a year, no matter how many times the site is rebuilt. The rule and the filenames were written a few minutes apart and contradicted each other. So the bundles are hashed now, which makes the caching correct rather than wrong, and the cost is exactly the thing the rule creates: nothing downstream may name them literally. `build-artifact.ts` finds them by pattern. So does `build-site.ts` — whose own first version listed `viewer.js` by name in its size report, and fell over on the very build that introduced the hash. The mistake and its consequence landed in the same commit. The cache rules now live in a `_headers` file written into the output, where the host looks for them: a year on the hashed bundles, and revalidation on the HTML, which must NOT be cached that way — it is what points at the current hash, and a stale copy of it pins a visitor to a build that no longer exists. Second: the README had grown a hosting comparison — which providers are free with a private repository, what GitHub Pages costs. None of that belongs in a README. It is a public-facing document about a model registry, read by people deciding whether to install it, and my deployment arithmetic is neither their business nor true for their situation. What stays is the part that is about this project: the command, what the output is, and that nothing is fetched at run time. `vercel.json` goes with it, since it was config for a host this project does not use.
37 lines
1.4 KiB
TypeScript
37 lines
1.4 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url'
|
|
import { defineConfig } from 'vite'
|
|
|
|
/**
|
|
* A separate build for embedding the viewer into a single-file Artifact.
|
|
* `scripts/build-artifact.ts` collapses the output into one HTML file.
|
|
*/
|
|
export default defineConfig({
|
|
resolve: {
|
|
alias: [
|
|
{ find: '@', replacement: fileURLToPath(new URL('./src', import.meta.url)) },
|
|
// `three` and `three/webgpu` are separate bundles; loading both packs the
|
|
// core twice and breaks instanceof checks. The regex is required — a plain
|
|
// string prefix match would break the `three/addons/...` path too.
|
|
{ find: /^three$/, replacement: 'three/webgpu' },
|
|
],
|
|
},
|
|
build: {
|
|
outDir: 'dist-viewer',
|
|
emptyOutDir: true,
|
|
target: 'esnext',
|
|
cssCodeSplit: false,
|
|
rollupOptions: {
|
|
input: fileURLToPath(new URL('./viewer.html', import.meta.url)),
|
|
output: {
|
|
inlineDynamicImports: true,
|
|
// CONTENT HASHED, and not for tidiness. The published site serves
|
|
// these with a year of immutable caching, which is only ever correct
|
|
// if the name changes when the bytes do: at the fixed `viewer.js` a
|
|
// returning visitor would have been handed a year-old bundle after
|
|
// every future deploy. `build-artifact.ts` finds them by pattern.
|
|
entryFileNames: 'viewer-[hash].js',
|
|
assetFileNames: 'viewer-[hash][extname]',
|
|
},
|
|
},
|
|
},
|
|
})
|