Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Grunt go into devDependencies?

Tags:

npm

gruntjs

The Grunt documentation states that it (and any plugins) should be included in the devDependencies section of package.json. I'm probably missing something obvious, but I can't see why. If I want to deploy a production version of my app, I still need to build it. And if I'm not building it, then why do I need Grunt?

In other words, imagine I pull my repo and say:

npm install --production

How do I now build my app if Grunt is in the devDependencies section?

like image 391
Matthew Gertner Avatar asked Jun 20 '13 16:06

Matthew Gertner


People also ask

Why do you need devDependencies?

devDependencies are those packages in the package. json file that you need only for project development purposes. Example- Babel, Webpack, etc. You require these packages to test and run your project on the localhost.

What does devDependencies mean?

DevDependencies are the packages a developer needs during development. A peer dependency specifies that our package is compatible with a particular version of an npm package.

What is devDependencies in package json?

"dependencies" : Packages required by your application in production. "devDependencies" : Packages that are only needed for local development and testing.

Should webpack be in dependencies or devDependencies?

Packages required to build the webpack project are under dependencies, rather than devDependencies . Node is historically used as a “server”, and still considered true.


2 Answers

What are you using Grunt for?

Grunt is typically listed in the devDependencies because even when you are deploying it for production, you would still need to compile things like CoffeeScript, SASS, etc.

In our case, it looks like this: we check in latest changes to GitHub, and then our deploy scripts log into the server, pulls the latest code from GitHub master, runs npm install and then grunt production.

Then we have a clean production build of the site on the server.

like image 117
robtarr Avatar answered Nov 15 '22 21:11

robtarr


Typically Grunt is used in development, it potentially handles testing, stylesheet pre-processors, javascript uglifying etc. You wouldn't distribute the Grunt related files as part of your production code, you would distribute the minified, tested, uglified code.

like image 44
Adam Simpson Avatar answered Nov 15 '22 21:11

Adam Simpson