DEV Community

Discussion on: Host Lovable.dev Project on github pages 😺

Collapse
 
poolshark profile image
Flo Ragossnig

A quick update. I have no clue if Github changed the default pages route now but according to their docs you must name your repo <username>.github.io. This will automatically be your base route (so https://.github.io). Therefore, in the vite.config.ts, the base path must be

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import { componentTagger } from "lovable-tagger";

export default defineConfig(({ mode }) => ({
  server: {
    host: "::",
    port: 8080,
  },
  plugins: [
    react(),
    mode === 'development' &&
    componentTagger(),
  ].filter(Boolean),
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
  base: '/' // Since this will be the base directory
}));
Enter fullscreen mode Exit fullscreen mode

Additionally, you need to change the base path destination in the workflow.yaml file accordingly


on:
  push:
    branches:
      - main

permissions:
  id-token: write 
  contents: write 
  pages: write    

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 18 

      - name: Vite GitHub Pages Deployer
        uses: skywarth/vite-github-pages-deployer@v1.5.0
        with:
          public_base_path: /  # This is the base
          build_path: ./dist
          install_phase_node_env: dev
          build_phase_node_env: production
          package_manager: npm
          artifact_name: github-pages
          debug_mode: false
          working_path: ./
Enter fullscreen mode Exit fullscreen mode
Collapse
 
coderatul profile image
Atul Kushwaha

my repo name is coderatul.github.io and i set base path to this only

in workflow : public_base_path: /coderatul.github.io/
and in vite config file: base: '/coderatul.github.io/'

and it works maybe you forgot : /repo name/ (the slashesh)

anyway i went through your github and yours seems working with base as / so thanks for commenting this people facing issue might get it right with base as /