I am starting a new project and would like to setup Grunt.js. Is there a particular command that will initialize a Grunfile.js with the boilerplate code structure?
Installing grunt-cli locally If you prefer the idiomatic Node. js method to get started with a project ( npm install && npm test ) then install grunt-cli locally with npm install grunt-cli --save-dev . Then add a script to your package. json to run the associated grunt command: "scripts": { "test": "grunt test" } .
The Grunt community is still going strong and both tools look like they're going to be around for a while yet. I should mention that another up and coming alternative to task runners like Grunt and Gulp is simply using npm scripts with command-line tools.
Grunt is a JavaScript task runner, a tool used to automatically perform frequent tasks such as minification, compilation, unit testing, and linting. It uses a command-line interface to run custom tasks defined in a file (known as a Gruntfile). Grunt was created by Ben Alman and is written in Node.
Grunt has its own set of init plugins for use with grunt-init
.
From the docs, some of the officially maintained plugins include
A few grunt-init templates are maintained officially:
- grunt-init-commonjs - Create a commonjs module, including Nodeunit unit tests.
- grunt-init-gruntfile - Create a basic Gruntfile.
- grunt-init-gruntplugin - Create a Grunt plugin, including Nodeunit unit tests.
- grunt-init-jquery - Create a jQuery plugin, including QUnit unit tests.
- grunt-init-node - Create a Node.js module, including Nodeunit unit tests.
If those don't suffice, yeoman also provides project scaffolding as well
I suggest you look at yeoman
.
It has generators and templates for creating various type of JS applications (from your own webapp to angular). It will create a base Grunt.js
for you and can use Bower to manage dependencies.
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