<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: MD.MIRAJUL ISLAM</title>
    <description>The latest articles on DEV Community by MD.MIRAJUL ISLAM (@miraz66).</description>
    <link>https://dev.to/miraz66</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1217094%2Fbee2455a-2dd2-48a3-82a8-6903af4b6d5a.jpeg</url>
      <title>DEV Community: MD.MIRAJUL ISLAM</title>
      <link>https://dev.to/miraz66</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/miraz66"/>
    <language>en</language>
    <item>
      <title>Deploy Vite React App to GitHub Pages 4 Step:</title>
      <dc:creator>MD.MIRAJUL ISLAM</dc:creator>
      <pubDate>Sun, 05 Jan 2025 14:15:15 +0000</pubDate>
      <link>https://dev.to/miraz66/deploy-vite-react-app-to-github-pages-4-step-320l</link>
      <guid>https://dev.to/miraz66/deploy-vite-react-app-to-github-pages-4-step-320l</guid>
      <description>&lt;h1&gt;
  
  
  Initialize Git, commit all the files and push them to your new repo:
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1st step:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git add -A
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2nd Step:
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git commit -m “first commit”&lt;br&gt;
git branch -M main&lt;br&gt;
git remote add origin https://github.com/[username]/[repo_name].git # Replace with your username and repo URL&lt;br&gt;
git push -u origin main&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  3rd step:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Set &lt;code&gt;base&lt;/code&gt; path in &lt;code&gt;vite.config.ts&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/ vite.config.ts
import { defineConfig } from “vite”;
import react from “@vitejs/plugin-react”;

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
base: “/vite-react-deploy/”, // YOUR REPO NAME HERE
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4th step:
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Add a GitHub workflow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Create a &lt;code&gt;deploy.yml&lt;/code&gt; file inside the &lt;code&gt;.github/workflows&lt;/code&gt; &lt;code&gt;directory.Copy&lt;/code&gt; and paste this workflow:&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: Deploy

on:
  push:
    branches:
      - main

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repo
        uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3

      - name: Install dependencies
        uses: bahmutov/npm-install@v1

      - name: Build project
        run: npm run build

      - name: Upload production-ready build files
        uses: actions/upload-artifact@v3
        with:
          name: production-files
          path: ./dist

  deploy:
    name: Deploy
    needs: build
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'

    steps:
      - name: Download artifact
        uses: actions/download-artifact@v3
        with:
          name: production-files
          path: ./dist

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./dist
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  On your repo page:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;1. Go to Settings → Actions → General,&lt;/li&gt;
&lt;li&gt;2. Scroll down to Workflow Permissions,&lt;/li&gt;
&lt;li&gt;3. Choose Read and Write, and save:&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Re-run actions:
&lt;/h2&gt;

&lt;p&gt;Actions → choose a failed deployment → Re-run failed jobs. Wait until in finishes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Configure GitHub Pages:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go to Settings → Pages&lt;/li&gt;
&lt;li&gt;Under Source, choose “Deploy from branch” and select the “gh-pages” branch.&lt;/li&gt;
&lt;li&gt;Click Save.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Most important things.
&lt;/h2&gt;

&lt;p&gt;Project name, Link name(base value) or Repo name most be same name create.&lt;/p&gt;

</description>
      <category>vite</category>
      <category>javascript</category>
      <category>programming</category>
      <category>react</category>
    </item>
  </channel>
</rss>
