diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..7db0fea --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,44 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: [main] + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 24 + cache: npm + + - run: npm ci + + - name: Build + run: npm run build + + - uses: actions/upload-pages-artifact@v3 + with: + path: web/dist + + deploy: + needs: build + runs-on: ubuntu-24.04 + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@v4 diff --git a/web/index.html b/web/index.html index 4c45aa7..8a5283e 100644 --- a/web/index.html +++ b/web/index.html @@ -3,7 +3,7 @@ - Game Gallery + Vibe Coded @@ -12,7 +12,7 @@ - +
-

Game Gallery

+

Vibe Coded

diff --git a/web/src/main.tsx b/web/src/main.tsx index 2d05ee9..e3215fc 100644 --- a/web/src/main.tsx +++ b/web/src/main.tsx @@ -5,7 +5,7 @@ import { ThemeProvider } from "@/components/theme-provider"; import { routeTree } from "./routeTree.gen"; import "./index.css"; -const router = createRouter({ routeTree }); +const router = createRouter({ routeTree, basepath: "/vibe-coded" }); declare module "@tanstack/react-router" { interface Register { diff --git a/web/vite.config.ts b/web/vite.config.ts index ca7be6f..6370867 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -1,12 +1,32 @@ +import fs from "fs"; import path from "path"; -import { defineConfig } from "vite"; +import { defineConfig, type Plugin } from "vite"; import react from "@vitejs/plugin-react"; import tailwindcss from "@tailwindcss/vite"; import { TanStackRouterVite } from "@tanstack/router-plugin/vite"; +function spaFallback(): Plugin { + return { + name: "spa-fallback", + closeBundle() { + const dist = path.resolve(__dirname, "dist"); + fs.copyFileSync( + path.join(dist, "index.html"), + path.join(dist, "404.html"), + ); + }, + }; +} + // https://vite.dev/config/ export default defineConfig({ - plugins: [TanStackRouterVite({ target: "react" }), react(), tailwindcss()], + base: "/vibe-coded/", + plugins: [ + TanStackRouterVite({ target: "react" }), + react(), + tailwindcss(), + spaFallback(), + ], resolve: { alias: { "@": path.resolve(__dirname, "./src"),