1

This is my gh-pages repo: https://github.com/Squinnb/acquco/tree/gh-pages main branch repo: https://github.com/Squinnb/acquco

I'm using Vite, Yarn, and React(TypeScript) and I will post contents of the package.json file:

{
  "name": "acquco",
  "private": true,
  "version": "0.0.0",
  "homepage": "https://squinnb.github.io/acquco",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "tsc && vite build",
    "preview": "vite preview",
    "predeploy": "yarn run build",
    "deploy": "gh-pages -d dist"
  },
  "dependencies": {
    "@types/react-router-dom": "^5.3.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.4.3"
  },
  "devDependencies": {
    "@types/react": "^18.0.24",
    "@types/react-dom": "^18.0.8",
    "@vitejs/plugin-react": "^2.2.0",
    "gh-pages": "^4.0.0",
    "typescript": "^4.9.3",
    "vite": "^3.2.3"
  }
}

Lastly the web page url: https://squinnb.github.io/acquco/ and image of the error: error console

Any suggestion would be helpful. Thanks.

Squinnb
  • 37
  • 5

1 Answers1

2

You're building GitHub Pages from main not from the gh-pages branch. Go to your repo settings, click on Pages on the left-hand column, and change the branch selection to gh-pages to use the built assets rather than the source files.

Zac Anger
  • 6,983
  • 2
  • 15
  • 42
  • Ooh you are right, thanks! I still get a 404 error message but it is a little different now. When I look at the source folder in the chrome dev console it has the root directory acquco/index.html, and then a sibling(to acquco dir) assets/index.css. It should be just one root dir acquco/ with a index.html favicon and assets/ dir with index.css AND index.js but this isn't the case for some reason. Any ideas why? – Squinnb Nov 26 '22 at 20:52
  • 2
    The new 404 is because Vite by default is using `/` as the root, but you're not serving your assets from the root of the domain. You can fix this by adding `base: './'` or `base: '/acquco/'` to `vite.config.js` as mentioned in [this issue](https://github.com/vitejs/vite/issues/238). – Zac Anger Nov 26 '22 at 21:18