Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vuejs & npm - Should all dependencies be devDependencies?

I am building a plugin component for Vue.js. Using a standard webpack configuration with vue-loader etc.

In a simple library I put modules that I expect to 'require' inside my dependencies in package.json. However since Webpack will be compiling all my code and dependencies into a single bundle I'm not sure where to put a dependency like: axios.

Would appreciate someone shedding some light onto this.

like image 765
user3690467 Avatar asked Mar 24 '18 17:03

user3690467


2 Answers

Technically, when using a bundler like webpack, the result will not make a difference with regard to the output of your bundling process.

That being said, dividing the packages in dependencies and devDependencies still helps you (and others looking at your package.json) to understand which packages are meant to end up being a part of the bundle created (dependencies), and which are needed to build the bundle only (devDependencies).

like image 156
connexo Avatar answered Nov 07 '22 21:11

connexo


There is already a good answer explaining difference between dependencies and devDependencies: https://stackoverflow.com/a/22004559/5157538

Just remember main principle:

If you need package in production put it into dependencies (most likely axios should be in dependecies in your case).

If you need package only during development, put it into devDependencies (e.g. unit-test libraries, which isn't needed in productions should be in devDependencies

like image 45
David Yunevich Avatar answered Nov 07 '22 21:11

David Yunevich