How to deploy a ReactAPP on GitHub Pages
- Install gh-pages
npm install gh-pages --save-dev
- vite.config.ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
base: "/el-nombre-de-tu-repositorio/",
});
- Add the next lines in the package.json
- With predeploy we compile the application.
- With deploy we deploy the site on github.
{
"scripts":{
"predeploy": "npm run build",
"deploy": "gh-pages -d dist"
}
}