DEV Community

Discussion on: Demystifying `devDependencies` and `dependencies`

Collapse
 
vilmes21 profile image
VM

Question: if I have code referencing a devDependency. And that code continue to exist on prod, my app would break, correct? Then should I remove my code when deploying?

Collapse
 
mshertzberg profile image
Michael Scott Hertzberg • Edited

Hi Vic,

If your code references a dependency, it should be in dependencies, otherwise your app will break. You'd generally reserve devDependencies for things like babel plugins and presets, test runners. Things that are needed to compile your application.

Collapse
 
vilmes21 profile image
VM

Make sense. Thank you.

Collapse
 
alanaasmaa profile image
Alan Aasmaa • Edited

Also one option would be to check envoriment. And when building for production uglify removes unnecessary code. See more in uglify documentation.

I actually use this also for building multible different sites from one source.