DEV Community

Discussion on: Deploy a Vue app with a Nodejs backend to Heroku

Collapse
 
junkern profile image
Martin

That's a good question and one I also asked myself before writing that article. What are the alternatives?
Building the application one my local machine and commiting the dist folder? And, because I would often forget to build my project before committing, I would add a pre-commit hook which builds the project.
However, some people consider adding build artifacts as bad practice 🤷‍♂️
We are actually on the same page here, I am also against installing dev dependencies on a production server. But often things are a trade off and for this project, I decided to install dev dependencies and against having build artifacts in my repo.

Do you have another alternative in mind?

Collapse
 
dakujem profile image
Andrej Rypo

How about making the necessary "dev" deps into production ones? That's what you do with PHP at least - you only install dev deps for your local/dev and test environments, but install the production deps only once you deploy the app to production.

I'm not yet versed with JS, it might be different there, but what other purpose would there be in dev deps, if they were supposed to be installed every time anyway? It wouldn't make sense. (Although that would not be the first time something made no sense in JS 😁).
Like, you don't need Vue CLI service for production, right? Neither a linter. My assumption is this, the "production" deps are meant for environments like Node, where "dev" ones can be omitted, but you still need the "dev" ones to build a production build, which you are doing in the build step of the Heroku deployment.

Thread Thread
 
junkern profile image
Martin • Edited

(Disclaimer: I am also not really knowledgeable with the whole React/Vuejs build pipeline, so I might state wrong things. Maybe I should spent some time in the future to look further into the build things)

You are perfectly explaining the approach React is taking: They add their built tool to the prod dependencies. Vue.js has a different approach/philosophy. I might try out your idea with the next project, but it probably won't work. The CLI service actually provides the build command to build the project. There might be a way to do it "light weight" (which I don't know of) but I am not very confident it will work. I am writing my Vue projects with Typescript, so I would need the whole TypeScript dependencies.

But you are right, when you use the approach written in the article, it does not make any sense to have build tools in the dev dependencies. Let's see if I try another solution the next time I use Vue.js on Heroku.

Thanks for raising those valid points!