feat: update next.config.js to handle GitHub Pages and improve basePath configuration

This commit is contained in:
2026-01-20 00:18:18 +00:00
parent 93d707c79d
commit 5d1302585a

View File

@@ -1,8 +1,15 @@
/* eslint-env node */
/** @type {import('next').NextConfig} */
const isGithubPages = process.env.GITHUB_PAGES === 'true' || process.env.GITHUB_ACTIONS === 'true'
const repoBasePath = process.env.NEXT_PUBLIC_BASE_PATH
|| (isGithubPages && process.env.GITHUB_REPOSITORY
? `/${process.env.GITHUB_REPOSITORY.split('/')[1]}`
: '')
const nextConfig = {
output: process.env.BUILD_STATIC ? 'export' : 'standalone',
basePath: process.env.NEXT_PUBLIC_BASE_PATH || '',
output: process.env.BUILD_STATIC || isGithubPages ? 'export' : 'standalone',
basePath: repoBasePath,
assetPrefix: repoBasePath || undefined,
images: {
unoptimized: true,
},