Skip to content

Host Vite React Project on Github Pages

  1. Install gh-pages package npm install --save-dev gh-pages

  2. 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"
}
}
  1. Configure vite.config.js
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

export default defineConfig({
  base: "/<repo-name>/",
  plugins: [react()],
});
  1. Initialise GIT, connect to repo, push
  2. Build and deploy project npm run deploy

Comments