Syntactic Fructose
Syntactic Fructose

Reputation: 20076

How to deploy a node.js application to heroku that lies within a subfolder of a repository

I'm unsure how to deploy my web application to heroku where the actual web application is generated within a sub folder. I have the project tree:

app
assets
dist
server
// other stuff ....

now when I want to run my server & frontend, I do gulp. gulp creates a folder named build which contains all needed files for running the web app, so my file tree would become

app
assets
dist
server
build
// other stuff ....

Is there a way to initialize the heroku repository to only the folder build? Since my actual web app lies inside just that folder, it's probably easier for me to only have heroku think the build folder exists.

I currently have heroku setup with only heroku create inside the parent repo

Upvotes: 0

Views: 111

Answers (1)

Syntactic Fructose
Syntactic Fructose

Reputation: 20076

I found a solution to my issue. What I decided to do was include my build folder into my repository (did not add much bloat, only like 50kb). Then, when I wanted to deploy to heroku I did:

git subtree split --prefix build -b deploy
git push heroku deploy:master
git branch -D deploy

this created a branch with only the build folder, pushed that to heroku (use -f if you need to overwrite previous commits), the deleted the deploy branch.

Worked like a charm!

Upvotes: 1

Related Questions