c0c99a9672
The server still never sees a photo, so the model has to run in the page. Real-ESRGAN x4v3 ships as a 4.9MB ONNX in public/models and is loaded lazily on the first export that actually needs it; the wasm runtime is copied next to CanvasKit at build time and stays lazily fetched, cached for 30 days. Vite is told onnxruntime-web is external-wasm so no 28MB asset lands in the bundle. UNCHANGED keeps the old path and the tier cap; 2K/4K/custom upscale only when the request is larger than the photo being edited, otherwise they resize down. Guests keep UNCHANGED and 2K. Tiling is 256px with an 8px overlap, so memory follows the target size rather than four times it.
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
import { defineConfig } from 'vite';
|
|
import react from '@vitejs/plugin-react';
|
|
import { fileURLToPath, URL } from 'node:url';
|
|
|
|
// The app is shared source with the React Native app: `frameUtils.ts` and
|
|
// `skiaImage.ts` import `@shopify/react-native-skia`, and the alias below swaps
|
|
// that for the CanvasKit adapter. Same trick the W0 spike used, now for the app.
|
|
export default defineConfig({
|
|
plugins: [react()],
|
|
resolve: {
|
|
// onnxruntime-web ships two flavours of its default entry: one with the
|
|
// runtime's wasm inlined as a build asset, one that fetches it at runtime.
|
|
// This picks the second, so the 28MB binary is served from /wasm/ort/ (see
|
|
// scripts/copy-wasm.mjs) instead of being emitted twice into dist.
|
|
conditions: ['onnxruntime-web-use-extern-wasm'],
|
|
alias: {
|
|
'@shopify/react-native-skia': fileURLToPath(new URL('./src/engine/skiaShim.ts', import.meta.url)),
|
|
},
|
|
},
|
|
build: {
|
|
target: 'es2022',
|
|
// canvaskit-wasm's glue JS is ~2.5MB on its own; the wasm is fetched at
|
|
// runtime from /wasm/, never bundled.
|
|
chunkSizeWarningLimit: 9000,
|
|
},
|
|
server: {
|
|
port: 5173,
|
|
proxy: { '/api': process.env.API_ORIGIN ?? 'http://localhost:3000' },
|
|
},
|
|
});
|