Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to initialize Gruntfile.js?

Tags:

gruntjs

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?

like image 922
Matt Avatar asked Sep 11 '13 15:09

Matt


People also ask

How do I run grunt locally?

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" } .

Is grunt still used?

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.

What is Gruntfile?

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.


2 Answers

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

like image 176
dc5 Avatar answered Oct 14 '22 09:10

dc5


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.

like image 45
Ewan Avatar answered Oct 14 '22 09:10

Ewan