React
To configure and deploy your Vite React project to GitHub Pages at https://sriramreddydwarampudi.github.io/srisounds, follow these steps:
- Update vite.config.js
Modify your vite.config.js to set the correct base path. Since your repository is named srisounds, set the base property as follows:
import { defineConfig } from 'vite'; import react from 'vitejs/plugin-react';
export default defineConfig({ root: './src', plugins: [react()], build: { outDir: '../dist', minify: false, emptyOutDir: true, }, base: '/srisounds/', // Add this line for GitHub Pages });
- Install gh-pages
Install the gh-pages package to handle deployment:
npm install gh-pages --save-dev
- Update package.json
Add the following scripts to your package.json:
"scripts": { "build": "vite build", "predeploy": "npm run build", "deploy": "gh-pages -d dist" }
- Build and Deploy
Run the following commands to build and deploy your project to GitHub Pages:
npm run deploy
-
Verify Deployment
-
Go to your GitHub repository: sriramreddydwarampudi.github.io/srisounds.
-
Navigate to Settings > Pages.
-
Ensure the source is set to the gh-pages branch.
Your site will be live at:
https://sriramreddydwarampudi.github.io/srisounds/
Let me know if you encounter any issues!
The error occurs because gh-pages requires a Git repository with a configured origin remote or a repo option in your gh-pages configuration. Here's how you can fix it:
npm install gh-pages --save-dev
Step 1: Initialize a Git Repository
If your project is not yet a Git repository, initialize it:
git init
Step 2: Add a Remote Origin
Set up the remote repository for your project:
git remote add origin https://github.com/sriramreddydwarampudi/srisounds.git
Step 3: Push Your Code to GitHub
Ensure your project is pushed to GitHub:
git add . git commit -m "Initial commit" git branch -M main git push -u origin main
Step 4: Retry Deployment
Run the deployment command again:
npm run deploy
Alternative: Use the repo Option
If you cannot set up a remote for some reason, you can specify the repo URL directly in your package.json:
"scripts": { "deploy": "gh-pages -d dist -r https://github.com/sriramreddydwarampudi/srisounds.git" }
Then run:
npm run deploy
Let me know if you encounter further issues!