I've found the source of error. With this configuration you should have deploy from gh-pages branch:

Deploying First Vite Project on GitHub Pages
reactjs - Vite + react application: unable to deploy to github pages - Stack Overflow
reactjs - Blank page when deploying a react app to github pages and vite - Stack Overflow
reactjs - Deploying a React application on GitHub Pages - Stack Overflow
Videos
Hello, I'm creating a simple Note Recorder app with Vite. As many people suggest, I'm trying to track my project with Git and Github. My repository is working fine and I learned how to push recent changes.
However, when I build and deploy my project for "gh-pages", a new branch is created which only contains a "dist" folder.
Is it a good practice to have a "main" branch for inspecting my code as it is originally structured and a "gh-pages" (or whatever name) branch for deploying it?
The purpose of all this is having a portfolio on my resume so recruiters can take a look. This project is simple and uses Local Storage. I want to add more projects in the future using other tools such as Nextjs and a Mongo or Postgres database.
I see that you have managed to deploy your React project to Github pages successfully, but here is how I did it in case anyone needs help:
- First things first, make sure that your ".git" folder and your project are in the same folder.

- Run
npm run build. You should have adistfolder now. - Open the file
vite.config.js(or.ts). - Add the
basefile with your repository name. Include the two/.
Example: let's say your github project's URL is https://github.com/atlassian/react-beautiful-dnd.
export default defineConfig({
base: "/react-beautiful-dnd/",
plugins: [react()],
});
- Open your
.gitignorefile and delete thedistline from it. You want to make sure that thedistfolder is pushed to github. git add .git commit -m "deploy"git subtree push --prefix dist origin gh-pages- Wait for a couple minutes (in my case it took 4 minutes) and open the page. In the example above, the URL would look like this: https://atlassian.github.io/react-beautiful-dnd
In case it's still showing a blank page, it's very likely to do with the step number 3. Ensure you added the correct repository URL and that it begins and ends with the / sign.
That is about it, I hope it helps. I used this blog post for guidance, it is a more detailed explanation of the above.
Ok, so to solve this the only thing that I had to do was to add base:"{repName}" to the vite.config.ts file.
Source: https://vitejs.dev/guide/static-deploy.html
The images were not loading, I used this to fix them: Github pages vite JS build not showing the images