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

* chore(docs): static assets cdn

* r2 env vars

* embed asset url directly
This commit is contained in:
Alaister Young authored and GitHub committed 2025-02-05 15:58:07 +00:00
1 parent 783b715a7f
commit f255627391
4 files changed
+27 -2

No files matched your search

+16
View File
@@ -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)}`
}
+2 -1
View File
@@ -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",
+6 -1
View File
@@ -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/**"]
+3
View File
@@ -0,0 +1,3 @@
{
"buildCommand": "pnpm build"
}