Choosing between dependencies and dev dependencies

I understand various types of dependencies when making libraries, but I still can't figure out whether it's worth dividing dependencies into different groups for applications. Let's say I use Vite, and how do I figure out where to put it? I use it for building and for running the app after it's built in production. So do I actually use it for production? Should I put such builders and runners as Vite in regular dependencies? Also, I use SASS. I know that It's needed for the building stage only. So should it be a development dependency? This leads me to another question: is building considered part of the production or development stage? Should dependencies required for the build process be placed in development dependencies or regular dependencies?
19 Replies
b1mind
b1mind•2w ago
Vite sorts most that for you anyway, but all of it should be a dev dependency. If you build fails because vite didn't ship something then move it to a dependency. (you will learn what is a "runtime dep" the more you get into using libs) How you deploy depends on what you're building. I.e. static/SSR etc. where your deploying too, etc. Building is for production and or testing locally aka preview. During development with vite you should be using run dev script
zobweyt
zobweyt•2w ago
So building is more about development rather than production?
b1mind
b1mind•2w ago
no npm run build is for production or testing locally npm run dev is for development or w/e package manager you use pnpm goated
zobweyt
zobweyt•2w ago
but to build the app you anyway need some development dependencies
b1mind
b1mind•2w ago
yes and those are dev dependencies
zobweyt
zobweyt•2w ago
so you are doing a build with development dependencies installed
b1mind
b1mind•2w ago
dependencies are things needed to be in /node_modules/ for production Not during build step Chances are you are not using anything that needs to be a dependacy again keep it all in dev deps Vite will tell you during build if so. Also if you were using create vite or w/e it should be putting stuff where it needs to be Like what are you using Vite for just Sass?
zobweyt
zobweyt•2w ago
Should I move everything to development dependencies and then attempt to build the app with all the development dependencies installed, and then preview using the start script? I understand that the next steps may depend on the hosting environment. For example, in one scenario, would I move the build to a hosting service and only install production dependencies there? I still need Vite to run the start script, so should it remain in the regular dependencies?
zobweyt
zobweyt•2w ago
I'm using Vite with Solid Start https://github.com/solidjs/solid-start
GitHub
GitHub - solidjs/solid-start: SolidStart, the Solid app framework
SolidStart, the Solid app framework. Contribute to solidjs/solid-start development by creating an account on GitHub.
b1mind
b1mind•2w ago
So your package.json should look like this yes? oh sorry like this ah nvm I can't find a vite example lol
zobweyt
zobweyt•2w ago
yes but it's more like a "library", not an app also, compare these examples: - https://github.com/solidjs/solid-start/blob/main/examples/bare/package.json: everything is in regular dependencies - https://github.com/solidjs/solid-start/blob/main/examples/with-vitest/package.json everything is in dev dependencies
GitHub
solid-start/examples/with-vitest/package.json at main · solidjs/sol...
SolidStart, the Solid app framework. Contribute to solidjs/solid-start development by creating an account on GitHub.
b1mind
b1mind•2w ago
yea exactly xD
zobweyt
zobweyt•2w ago
they are using vinxi, it's vite + nitro
b1mind
b1mind•2w ago
yea I see that now interesting but yes it all should be in dev deps 😄 like i've been saying There are very few things you will need peer deps/deps for. When you know you will know typically
zobweyt
zobweyt•2w ago
okay, got it however, this still remains unclear for me:
I still need Vite to run the start script, so should it remain in the regular dependencies?
b1mind
b1mind•2w ago
no all of it should be in dev deps vite especially
zobweyt
zobweyt•2w ago
maybe I don't understand very well why start script is needed? is it needed only for testing and preview? after moving the build to the hosting service, do I need to run the application using just node and the resulting build?
b1mind
b1mind•2w ago
Vite is only for development/building after its build it shouldn't be shipped depends on the hosting? but yes you would just run node if you are using SSR using like entrypoint index.js (what ever its named in start) CMD ["node", "./build/index.js"] I'm running in docker but you get the idea All thier docs mainly show how to deploy to the typical serverless paas companies xD can't help ya there 😄
zobweyt
zobweyt•2w ago
ohhh, thank you very much!! I got it all now :)
Want results from more Discord servers?
Add your server