Host Vite React Project on Github Pages
-
Install gh-pages package
npm install --save-dev gh-pages
-
Update package.json Add homepage field with your github pages url
{
"name":"my-project-name",
"homepager": "https://github.com/levoxtrip/MyDashboard",
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d dist"
}
}
- Configure vite.config.js
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
base: "/<repo-name>/",
plugins: [react()],
});
- Initialise GIT, connect to repo, push
- Build and deploy project
npm run deploy