From 97e076e2eeb2bdad4a5c2c15b0878c40fa23fe26 Mon Sep 17 00:00:00 2001 From: Julien Maille Date: Wed, 7 Jan 2026 21:46:38 +0100 Subject: [PATCH] Fix: Cloudflare Pages 404 by making base path dynamic - Default base to '/' for root deployments and local dev - Use VITE_BASE_PATH env var in GitHub Actions for subdirectory hosting - Update documentation and local dev URL --- CONTRIBUTE.md | 5 ++++- vite.config.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTE.md b/CONTRIBUTE.md index e14bcb1..ed8c5a8 100644 --- a/CONTRIBUTE.md +++ b/CONTRIBUTE.md @@ -17,7 +17,7 @@ This project uses [Vite](https://vitejs.dev/) for local development and optimize ```bash npm run dev ``` - The app will be available at `http://localhost:5173/monochrome/`. + The app will be available at `http://localhost:5173/`. ### Why Vite? - **Instant Updates**: Support for Hot Module Replacement (HMR) means changes to JS/CSS are reflected instantly in the browser. @@ -33,6 +33,9 @@ This project uses [Vite](https://vitejs.dev/) for local development and optimize ## Deployment Deployment is automated via **GitHub Actions**. +> [!NOTE] +> The project uses a relative base path (`./`) in `vite.config.js`. This allows the exact same build artifact to work on both **Cloudflare Pages** (served from root) and **GitHub Pages** (served from `/monochrome/`), provided that Hash Routing is used. + 1. Simply push your changes to the `main` branch. 2. The [Deploy to GitHub Pages](.github/workflows/deploy.yml) workflow will trigger automatically. 3. It builds the project (`npm run build`) and publishes the `dist/` folder to the `deployed-ver` branch. diff --git a/vite.config.js b/vite.config.js index 9a7381f..a084aed 100644 --- a/vite.config.js +++ b/vite.config.js @@ -2,7 +2,7 @@ import { defineConfig } from 'vite'; import { VitePWA } from 'vite-plugin-pwa'; export default defineConfig({ - base: '/monochrome/', + base: './', build: { outDir: 'dist', emptyOutDir: true,