DEV Community

kuuudo
kuuudo

Posted on

Vite + Three.js site works in dev, but 404s on GitHub Pagesβ€”can’t find main.ts. Tried setting base + homepage. Any ideas? πŸ™

Hey everyone,
I’m currently working on a project using Three.js, Vite, and TypeScript. I want to make it a published website, and I’m using GitHub Pages as the hosting platform. Everything works perfectly when I run npm run dev, but when I try to run npm run preview, or when I deploy it to GitHub Pages, it just shows a blank (white) canvas.
When I open the browser console (F12), I get a 404 error saying it can’t find my main.ts file.
Here’s what I’ve tried so far:
I added this line in my package.json: "homepage": "https://kuuudo.github.io/roberterrante/"
I also updated vite.config.js to include: base: '/roberterrante/',
But none of this seems to fix the issue.
I also have a mobile.ts file that should load instead of main.ts when a mobile device is detected, but I haven’t gotten that part to work in the deployed version either.
Also, just a heads up β€” this is my first website project, and I probably put too many unnecessary files in the src folder πŸ˜…. There are files like car.ts, box.ts, eve.ts, followCam.ts, game.ts, keyboard.ts, main.js, othermain.ts, and a few others I’m honestly too afraid to delete right now, in case they break something.
Any ideas what I might be missing? I'd really appreciate your help!

πŸ”— Live website:
πŸ‘‰ https://kuuudo.github.io/roberterrante/
πŸ’» GitHub repository:
πŸ‘‰ https://github.com/kuuudo/roberterrante

Image description

Image description

Top comments (0)