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?
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.
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.
"dependencies" : Packages required by your application in production. "devDependencies" : Packages that are only needed for local development and testing.
Packages required to build the webpack project are under dependencies, rather than devDependencies . Node is historically used as a “server”, and still considered true.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With