Skip to content

Comments

Fix GitHub Pages 404s by setting correct base path for production builds#12

Merged
lawvs merged 5 commits intomainfrom
copilot/fix-ghpages-error
Feb 8, 2026
Merged

Fix GitHub Pages 404s by setting correct base path for production builds#12
lawvs merged 5 commits intomainfrom
copilot/fix-ghpages-error

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

GitHub Pages deployment at https://www.waterwater.moe/eagle-plugin-mini-map/ was returning 404s for fixture URLs. Absolute paths like /tests/fixtures/... were missing the /eagle-plugin-mini-map/ repository prefix.

Changes

Vite base path (vite.config.ts)

  • Uses VITE_BASE_PATH environment variable for configurable base path
  • Defaults to "./" (relative) when env var is not set
  • Allows GitHub Pages deployment with correct repository-prefixed paths
export default defineConfig({
  base: process.env.VITE_BASE_PATH || "./", // for Eagle Plugin
  plugins: [react(), tailwindcss()],
});

Dynamic mock URLs (src/eagle/mock.ts)

  • Replaced hardcoded /tests/fixtures/... with import.meta.env.BASE_URL + 'tests/fixtures/...'
  • Adapts to Vite's base configuration automatically

Build process (package.json)

  • Build script uses native cp -r command to copy test fixtures to public/ before Vite build
  • Added public/tests to .gitignore (build artifact)

GitHub Actions workflow (.github/workflows/build.yml)

  • Added VITE_BASE_PATH environment variable to the Build step
  • Set to /eagle-plugin-mini-map/ for production builds
- name: Build
  run: pnpm run build
  env:
    VITE_BASE_PATH: /eagle-plugin-mini-map/

Result: URLs resolve correctly as https://www.waterwater.moe/eagle-plugin-mini-map/tests/fixtures/... when deployed to GitHub Pages, while maintaining relative paths for local development and Eagle plugin usage.

Original prompt

Fix error in ghpages

Failed to fetch source (404)

Error url: https://www.waterwater.moe/tests/fixtures/MJXX6FDDBW3FZ.info/DSC02497.jpg

The repo is https://github.com/lawvs/eagle-plugin-mini-map
so miss eagle-plugin-mini-map in ghpages url


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 8, 2026 15:29
- Update Vite config to use /eagle-plugin-mini-map/ base for production
- Update mock URLs to use import.meta.env.BASE_URL
- Copy test fixtures to public during build for preview
- Add public/tests to .gitignore

Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com>
Replace cp command with copyfiles package for Windows compatibility

Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error in GitHub Pages for eagle-plugin-mini-map Fix GitHub Pages 404s by setting correct base path for production builds Feb 8, 2026
Copilot AI requested a review from lawvs February 8, 2026 15:33
@lawvs
Copy link
Owner

lawvs commented Feb 8, 2026

@copilot no need copyfiles, just use cp from shell

For vite config, remove the /eagle-plugin-mini-map/ hard code, use a env var for base, and fallback to default behovior(./), then tell me how to setting for github env var, I will config it for github env

export default defineConfig(({ mode }) => ({
  // Use relative path for Eagle Plugin, but absolute path for GitHub Pages deployment
  base: mode === "production" ? "/eagle-plugin-mini-map/" : "./",

- Replace hardcoded base path with VITE_BASE_PATH env var
- Fallback to "./" (relative) when env var not set
- Replace copyfiles with native cp command
- Remove copyfiles dependency

Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 8, 2026

@copilot no need copyfiles, just use cp from shell

For vite config, remove the /eagle-plugin-mini-map/ hard code, use a env var for base, and fallback to default behovior(./), then tell me h...

Done in commit c20fdf1.

Changes:

  • Removed copyfiles dependency and switched to cp command
  • Replaced hardcoded base path with VITE_BASE_PATH environment variable
  • Defaults to "./" when env var is not set

To configure the GitHub Actions workflow, add this to your build step in .github/workflows/build.yml:

- name: Build
  run: pnpm run build
  env:
    VITE_BASE_PATH: /eagle-plugin-mini-map/

This will set the base path for production builds while keeping local development and Eagle plugin builds using relative paths.

@lawvs
Copy link
Owner

lawvs commented Feb 8, 2026

@copilot Goods, add this to your build step in .github/workflows/build.yml:

  • name: Build
    run: pnpm run build
    env:
    VITE_BASE_PATH: /eagle-plugin-mini-map/

1 similar comment
@lawvs
Copy link
Owner

lawvs commented Feb 8, 2026

@copilot Goods, add this to your build step in .github/workflows/build.yml:

  • name: Build
    run: pnpm run build
    env:
    VITE_BASE_PATH: /eagle-plugin-mini-map/

Set VITE_BASE_PATH=/eagle-plugin-mini-map/ for production builds

Co-authored-by: lawvs <18554747+lawvs@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 8, 2026

@copilot Goods, add this to your build step in .github/workflows/build.yml:

  • name: Build
    ...

Done in commit 8ccdf42. Added the VITE_BASE_PATH environment variable to the Build step in .github/workflows/build.yml.

@lawvs lawvs marked this pull request as ready for review February 8, 2026 16:02
@lawvs lawvs merged commit a2baa65 into main Feb 8, 2026
1 check passed
@lawvs lawvs deleted the copilot/fix-ghpages-error branch February 8, 2026 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants