DEV Community

Discussion on: Deploying Vite App to GitHub Pages

Collapse
 
jelizarovas profile image
Arnas • Edited

Or add: base: "/<repo>/", to vite.config.js,

npm install gh-pages --save-dev

add to package.json

 "homepage": "https://<username>.github.io/<repo>/",
  ...
  "scripts": {
...
"build": "vite build",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d dist",
...
Enter fullscreen mode Exit fullscreen mode

and then run command npm run deploy to keep it simple.

Collapse
 
sagasanga profile image
Reckson Zirsangzela Khiangte

This is the way!

Collapse
 
milkdromeda333 profile image
Anjanique M.

This just saved my life. Thank you!!!

Collapse
 
selim9106 profile image
Selim Elyahyioui

I wish I had a vite.config.js but I don't (I config 2 projects with Vite + Vanilla JS (no TS) and added Tailwind to one of them). I don't know how to create a github page
Can you help me?

Collapse
 
xaypanya profile image
Xaypanya Phongsa

Thanks bro

Collapse
 
peresnegro profile image
Porkopek

THIS is the best method. Much faster deployment time than the article's one.
For a custom domain, change
in vite.config.js

base: "/"

and in package.json

"homepage": "your-custom-domain",

Besides that, you'll be free of git errors ocasionated by adding -f to git the dist folder and if an error is found, the folder dist got added to git, so your deploy is not going to work