Deploying an app using Vite on Heroku

Vite Heroku logos

As I’ve just stumbled about some problems deploying an app using Vite on heroku.com, I thought I might just help and spread the word (or article) from Harry Laoulakos’ blog. Before I kept having problems with opening my app – the deployment worked fine, but then my app kept going from starting to crashed or, depending on what I tried, going into a timeout error as the port couldn’t be bound within 60 seconds.

I already had heroku/nodejs added as buildpack as he suggests:
Heroku buildpack config view
The heroku/nodejs buildpack selected as buildpack for an app
The crucial changes for my setup were to add the following to my package.json
    "postinstall": "npm run build",
    "serve-heroku": "vite --host 0.0.0.0 --port $PORT preview",

and, to go alongside with it, create a Procfile (not Profile) file with the following content:

web: npm run serve-heroku

Hope this helps in case you run into similar issues.

1 thought on “Deploying an app using Vite on Heroku

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.