Skip to content

Commit bb193a4

Browse files
author
Miriad
committed
fix: gracefully skip Sanity typegen when env vars unavailable
The prebuild typegen step fails on Vercel because sanity.config.ts imports sanity/lib/api.ts which throws if NEXT_PUBLIC_SANITY_DATASET and NEXT_PUBLIC_SANITY_PROJECT_ID are not set. Even though these are configured in Vercel, they may not be available during the prebuild phase. This change makes typegen non-fatal — if it fails, the build continues using the already-committed types in sanity/types.ts.
1 parent 02914e2 commit bb193a4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"start": "next start",
77
"lint": "biome check .",
88
"predev": "npm run typegen",
9-
"prebuild": "npm run typegen",
9+
"prebuild": "npx sanity schema extract --path=./sanity/extract.json && npx sanity typegen generate || echo 'Sanity typegen skipped (env vars not available)'",
1010
"typegen": "sanity schema extract --path=./sanity/extract.json && sanity typegen generate",
1111
"format": "biome format . --write"
1212
},

0 commit comments

Comments
 (0)