Skip to content

Commit 80ea666

Browse files
committed
Enhance Vite configuration to dynamically set base path for GitHub Pages deployment
1 parent b284492 commit 80ea666

3 files changed

Lines changed: 77 additions & 6 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: npm
29+
30+
- name: Install dependencies
31+
run: npm install
32+
33+
- name: Build site
34+
run: npm run build
35+
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: dist
40+
41+
deploy:
42+
needs: build
43+
runs-on: ubuntu-latest
44+
environment:
45+
name: github-pages
46+
url: ${{ steps.deployment.outputs.page_url }}
47+
steps:
48+
- name: Deploy to GitHub Pages
49+
id: deployment
50+
uses: actions/deploy-pages@v4

AGENTS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
Synth is a Vite + React TypeScript project. Keep application logic inside `src/`, with `main.tsx` bootstrapping React and `App.tsx` arranging top-level layout. Reusable UI lives in `src/components/` using PascalCase filenames, while shared styles stay in `src/index.css` and design tokens in `tailwind.config.js`. Serve static assets from `public/`; avoid committing anything generated under `dist/`.
5+
6+
## Build, Test, and Development Commands
7+
Install dependencies with `npm install` (or `bun install` to respect `bun.lockb`). Use `npm run dev` for a hot-reloading development server. Run `npm run build` to compile a production bundle and surface TypeScript errors. Validate the built output locally via `npm run preview`. Keep the codebase lint-clean with `npm run lint`.
8+
9+
## Coding Style & Naming Conventions
10+
Use TypeScript throughout and prefer functional React components. Follow the existing two-space indentation and wrap JSX attributes to multiple lines when they exceed the formatter width. Name components and their files in PascalCase (`Logo.tsx`), hooks in camelCase (`useFeatureFlag`), and utility modules with kebab-case if added outside `components/`. Tailwind utility classes should describe layout-to-appearance order, matching current patterns. Linting is configured via `eslint.config.js`; fix or justify any warnings before opening a pull request.
11+
12+
## Testing Guidelines
13+
No automated test harness ships yet, so rely on `npm run lint` and manual verification until tests are introduced. When adding tests, colocate them beside components using the `Component.test.tsx` pattern and prefer React Testing Library with Vitest for consistency with the Vite ecosystem. Document any new test commands in `package.json` and reference them here.
14+
15+
## Commit & Pull Request Guidelines
16+
History favors concise, action-oriented commit messages (e.g., `Update layout spacing`). Write messages in the imperative mood and group related changes per commit. For pull requests, provide a summary of the user-facing effect, link any tracking issues, and attach screenshots or recordings when UI changes are involved. Note any follow-up tasks and ensure `npm run build` and `npm run lint` have been run before requesting review.

vite.config.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
33

4-
// https://vitejs.dev/config/
5-
export default defineConfig({
6-
plugins: [react()],
7-
optimizeDeps: {
8-
exclude: ['lucide-react'],
9-
},
4+
// Configure Vite to serve assets from the repository path when deployed to GitHub Pages.
5+
export default defineConfig(() => {
6+
const repoName = process.env.GITHUB_REPOSITORY?.split('/')?.[1];
7+
8+
return {
9+
base: repoName ? `/${repoName}/` : '/',
10+
plugins: [react()],
11+
optimizeDeps: {
12+
exclude: ['lucide-react'],
13+
},
14+
};
1015
});

0 commit comments

Comments
 (0)