chore: attempt to fix the basePath in preview deployments
This commit is contained in:
@@ -38,11 +38,17 @@ jobs:
|
|||||||
run: npm run test
|
run: npm run test
|
||||||
|
|
||||||
- name: Build application
|
- name: Build application
|
||||||
run: npm run build
|
run: |
|
||||||
|
echo "Building for branch: ${{ github.ref_name }}"
|
||||||
|
echo "NODE_ENV: $NODE_ENV"
|
||||||
|
echo "SURGE_PREVIEW: $SURGE_PREVIEW"
|
||||||
|
npm run build
|
||||||
env:
|
env:
|
||||||
NEXT_PUBLIC_GA_ID: ${{ secrets.NEXT_PUBLIC_GA_ID }}
|
NEXT_PUBLIC_GA_ID: ${{ secrets.NEXT_PUBLIC_GA_ID }}
|
||||||
NEXT_PUBLIC_REQUIRE_CONSENT: true
|
NEXT_PUBLIC_REQUIRE_CONSENT: true
|
||||||
NEXT_PUBLIC_ANONYMIZE_IP: true
|
NEXT_PUBLIC_ANONYMIZE_IP: true
|
||||||
|
# Set SURGE_PREVIEW for non-master branches to disable basePath
|
||||||
|
SURGE_PREVIEW: ${{ github.ref != 'refs/heads/master' && 'true' || '' }}
|
||||||
|
|
||||||
- name: Upload Pages Artifact (Production)
|
- name: Upload Pages Artifact (Production)
|
||||||
if: github.ref == 'refs/heads/master'
|
if: github.ref == 'refs/heads/master'
|
||||||
|
|||||||
+5
-2
@@ -4,8 +4,11 @@ const nextConfig: NextConfig = {
|
|||||||
// Output as static site for GitHub Pages
|
// Output as static site for GitHub Pages
|
||||||
output: 'export',
|
output: 'export',
|
||||||
|
|
||||||
// Base path for GitHub Pages (only in production)
|
// Base path for GitHub Pages (only in production AND not for Surge previews)
|
||||||
basePath: process.env.NODE_ENV === 'production' ? '/github-profile-readme-generator' : '',
|
basePath:
|
||||||
|
process.env.NODE_ENV === 'production' && !process.env.SURGE_PREVIEW
|
||||||
|
? '/github-profile-readme-generator'
|
||||||
|
: '',
|
||||||
|
|
||||||
// Image optimization for static export
|
// Image optimization for static export
|
||||||
images: {
|
images: {
|
||||||
|
|||||||
Reference in New Issue
Block a user