Skip to content

Open source personal finance application

fix(pwa): deploy as static prerendered SPA so SW precaches app shell for offline

Ilya Komichev7ef57b632e17
diff --git a/app/nuxt.config.ts b/app/nuxt.config.ts
index 48b5179d..fb644b07 100644
--- a/app/nuxt.config.ts
+++ b/app/nuxt.config.ts
@@ -151,6 +151,11 @@ export default defineNuxtConfig({
)
},
},
+ // Declare the static (prerendered SPA) output in the framework config so the build is
+ // host-agnostic and overrides Vercel's serverless preset auto-detection - otherwise the
+ // default `vercel` preset emits a serverless fallback with no static index.html and a
+ // precache whose _nuxt hashes desync from the served chunks, breaking offline.
+ preset: 'static',
},
pwa: {
diff --git a/app/vercel.json b/app/vercel.json
index 24723fbc..1c0edb1e 100644
--- a/app/vercel.json
+++ b/app/vercel.json
@@ -1,6 +1,7 @@
{
"installCommand": "pnpm install",
- "buildCommand": "pnpm --filter app build",
+ "buildCommand": "pnpm --filter app generate",
"outputDirectory": ".output/public",
- "ignoreCommand": "git diff --quiet HEAD^ HEAD -- . ../package.json ../pnpm-lock.yaml ../pnpm-workspace.yaml"
+ "ignoreCommand": "git diff --quiet HEAD^ HEAD -- . ../package.json ../pnpm-lock.yaml ../pnpm-workspace.yaml",
+ "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}