Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
const {withContentlayer} = require('next-contentlayer2');
/** @type {import('next').NextConfig} */

// in prod, we serve the docs from sourcegraph.com/docs, and this requires special config on the GFE side
// in preview/development, this is not necessary.
//
// VERCEL_ENV is a system env var set by Vercel
// https://vercel.com/docs/projects/environment-variables/system-environment-variables
const basePath = process.env.VERCEL_ENV === 'production' ? '/docs' : '';

const nextConfig = {
reactStrictMode: true,
swcMinify: true,
// in prod, we serve the docs from sourcegraph.com/docs, and this requires special config on the GFE side
// in preview/development, this is not necessary.
//
// VERCEL_ENV is a system env var set by Vercel
// https://vercel.com/docs/projects/environment-variables/system-environment-variables
// basePath: process.env.VERCEL_ENV === 'production' ? '/docs' : '',
basePath: process.env.VERCEL_ENV === 'production' ? '/docs' : '',
basePath,
env: {
NEXT_PUBLIC_DOCS_BASE_PATH:
process.env.VERCEL_ENV === 'production' ? '/docs' : ''
NEXT_PUBLIC_DOCS_BASE_PATH: basePath
},
// With basePath set, nothing serves `/`, so the *.vercel.app deployment URL
// that Vercel links from Slack / GitHub 404s. sourcegraph.com never proxies
// `/` to us, so this only affects visitors opening that raw URL. Stay on the
// same host so they see this exact deployment, not whatever is live.
async redirects() {
if (!basePath) return [];
return [
{
source: '/',
destination: basePath,
basePath: false,
permanent: false
}
];
}
};

Expand Down
Loading