Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore(docs): static assets cdn (#33347)

Alaister Youngf25562739148
diff --git a/apps/docs/next.config.mjs b/apps/docs/next.config.mjs
index 3fbd6234301..b4572b5640f 100644
--- a/apps/docs/next.config.mjs
+++ b/apps/docs/next.config.mjs
@@ -36,6 +36,7 @@ const withMDX = nextMdx({
/** @type {import('next').NextConfig} nextConfig */
const nextConfig = {
+ assetPrefix: getAssetPrefix(),
// Append the default value with md extensions
pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
// reactStrictMode: true,
@@ -171,3 +172,18 @@ const configExport = () => {
}
export default configExport
+
+function getAssetPrefix() {
+ // If not force enabled, but not production env, disable CDN
+ if (process.env.FORCE_ASSET_CDN !== '1' && process.env.VERCEL_ENV !== 'production') {
+ return undefined
+ }
+
+ // Force disable CDN
+ if (process.env.FORCE_ASSET_CDN === '-1') {
+ return undefined
+ }
+
+ // @ts-ignore
+ return `https://frontend-assets.supabase.com/${process.env.SITE_NAME}/${process.env.VERCEL_GIT_COMMIT_SHA.substring(0, 12)}`
+}
diff --git a/apps/docs/package.json b/apps/docs/package.json
index 7905bbe7cc9..22acfdf3dbc 100644
--- a/apps/docs/package.json
+++ b/apps/docs/package.json
@@ -8,10 +8,11 @@
"dev": "concurrently --kill-others \"next dev --port 3001\" \"pnpm run dev:watch:troubleshooting\"",
"dev:watch:troubleshooting": "node ./scripts/troubleshooting/watch.mjs",
"dev:secrets:pull": "AWS_PROFILE=supabase-dev node ../../scripts/getSecrets.js -n local/docs",
+ "prebuild": "pnpm run codegen:references && pnpm run codegen:examples",
"build": "next build",
"build:analyze": "ANALYZE=true next build",
"build:sitemap": "tsx ./internals/generate-sitemap.ts",
- "postbuild": "pnpm run build:sitemap",
+ "postbuild": "pnpm run build:sitemap && ./../../scripts/upload-static-assets.sh",
"start": "next start",
"lint": "next lint",
"lint:mdx": "supa-mdx-lint content --config ../../supa-mdx-lint.config.toml",
diff --git a/apps/docs/turbo.json b/apps/docs/turbo.json
index e9f478056fe..b349cadfbeb 100644
--- a/apps/docs/turbo.json
+++ b/apps/docs/turbo.json
@@ -40,7 +40,12 @@
"DOCS_REVALIDATION_KEYS",
"DOCS_REVALIDATION_OVERRIDE_KEYS",
"SUPABASE_SECRET_KEY",
- "OPENAI_API_KEY"
+ "OPENAI_API_KEY",
+ "AWS_ACCESS_KEY_ID",
+ "AWS_SECRET_ACCESS_KEY",
+ "FORCE_ASSET_CDN",
+ "ASSET_CDN_S3_ENDPOINT",
+ "SITE_NAME"
],
"inputs": ["$TURBO_DEFAULT$"],
"outputs": [".next/**", "!.next/cache/**"]
diff --git a/apps/docs/vercel.json b/apps/docs/vercel.json
new file mode 100644
index 00000000000..8df7e53755b
--- /dev/null
+++ b/apps/docs/vercel.json
@@ -0,0 +1,3 @@
+{
+ "buildCommand": "pnpm build"
+}