From 665ba83975fb2be96e6741ce6fb059e0bff7f0dd Mon Sep 17 00:00:00 2001 From: Dave Li Date: Tue, 2 Jul 2024 08:52:11 +0200 Subject: [PATCH] Add support for `sanity schema extract`. --- sanity.config.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/sanity.config.ts b/sanity.config.ts index 918970a..c99c48c 100644 --- a/sanity.config.ts +++ b/sanity.config.ts @@ -1,16 +1,15 @@ +const env = process.env ?? import.meta.env; + // Different environments use different variables const projectId = - import.meta.env.PUBLIC_SANITY_STUDIO_PROJECT_ID! || - import.meta.env.PUBLIC_SANITY_PROJECT_ID!; -const dataset = - import.meta.env.PUBLIC_SANITY_STUDIO_DATASET! || - import.meta.env.PUBLIC_SANITY_DATASET!; + env.PUBLIC_SANITY_STUDIO_PROJECT_ID! || env.PUBLIC_SANITY_PROJECT_ID!; +const dataset = env.PUBLIC_SANITY_STUDIO_DATASET! || env.PUBLIC_SANITY_DATASET!; // Feel free to remove this check if you don't need it if (!projectId || !dataset) { throw new Error( `Missing environment variable(s). Check if named correctly in .env file.\n\nShould be:\nPUBLIC_SANITY_STUDIO_PROJECT_ID=${projectId}\nPUBLIC_SANITY_STUDIO_DATASET=${dataset}\n\nAvailable environment variables:\n${JSON.stringify( - import.meta.env, + env, null, 2 )}`