forked from sanity-io/sanity-template-astro-clean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.mjs
37 lines (33 loc) · 1.28 KB
/
astro.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Loading environment variables from .env files
// https://docs.astro.build/en/guides/configuring-astro/#environment-variables
import { loadEnv } from "vite";
const {
PUBLIC_SANITY_STUDIO_PROJECT_ID,
PUBLIC_SANITY_STUDIO_DATASET,
PUBLIC_SANITY_PROJECT_ID,
PUBLIC_SANITY_DATASET,
} = loadEnv(import.meta.env.MODE, process.cwd(), "");
import { defineConfig } from "astro/config";
// Different environments use different variables
const projectId = PUBLIC_SANITY_STUDIO_PROJECT_ID || PUBLIC_SANITY_PROJECT_ID;
const dataset = PUBLIC_SANITY_STUDIO_DATASET || PUBLIC_SANITY_DATASET;
import sanity from "@sanity/astro";
import react from "@astrojs/react";
// Change this depending on your hosting provider (Vercel, Netlify etc)
// https://docs.astro.build/en/guides/server-side-rendering/#adding-an-adapter
import vercel from "@astrojs/vercel/serverless";
// https://astro.build/config
export default defineConfig({
// Hybrid+adapter is required to support embedded Sanity Studio
output: "hybrid",
adapter: vercel(),
integrations: [sanity({
projectId,
dataset,
studioBasePath: "/admin",
useCdn: false,
// `false` if you want to ensure fresh data
apiVersion: "2023-03-20" // Set to date of setup to use the latest API version
}), react() // Required for Sanity Studio
]
});