Skip to content

Latest commit

 

History

History
executable file
·
34 lines (31 loc) · 1.29 KB

Deploy-to-github.md

File metadata and controls

executable file
·
34 lines (31 loc) · 1.29 KB

To deploy a Vite app on GitHub Pages, follow these steps:

  1. Update Vite Config: Modify your Vite configuration to accommodate GitHub Pages deployment:
Copy code
// vite.config.js
import { defineConfig } from 'vite';

export default defineConfig({
  base: '/<repository-name>/',  // replace <repository-name> with your GitHub repository name
});
  1. Build Script: Update your package.json to include a build script that specifies the correct base URL:
"scripts": {
  "build": "vite build",
  "deploy": "gh-pages -d src/dist"  // Ensure you have the `gh-pages` package installed
}
  1. Install gh-pages: Install the gh-pages npm package if not already installed:
npm install gh-pages --save-dev
  1. Build Your App: Build your Vite application using the build script:
npm run build
  1. Deploy: Deploy your app to GitHub Pages:
npm run deploy
  1. GitHub Repository Settings: Go to your repository settings on GitHub, find the "Pages" section, and set the source to the gh-pages branch.

This will deploy your Vite app to GitHub Pages, accessible at https://.github.io//. Make sure to replace and with your GitHub username and the repository name, respectively.