Installing gruntplugins

suggest change

Adding dependcy

To use a gruntplugin, you first need to add it as a dependency to your project. Let’s use the jshint plugin as an example.

npm install grunt-contrib-jshint --save-dev

The --save-dev option is used to add the plugin in the package.json, this way the plugin is always installed after a npm install.

Loading the plugin

You can load your plugin in the gruntfile file using loadNpmTasks.

grunt.loadNpmTasks('grunt-contrib-jshint');

Configuring the task

You configure the task in the gruntfile adding a property called jshint to the object passed to grunt.initConfig.

grunt.initConfig({
  jshint: {
    all: ['Gruntfile.js', 'lib/**/*.js', 'test/**/*.js']
  }
});

Don’t forget you can have other properties for other plugins you are using.

Running the task

To just run the task with the plugin you can use the command line.

grunt jshint

Or you can add jshint to another task.

grunt.registerTask('default', ['jshint']);

The default task runs with the grunt command in the terminal without any options.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


grunt:
* grunt
* Installing gruntplugins

Table Of Contents
1 npm
41 cli
43 grunt
59 Hack
64 ES6
67 Redis
69 MongoDB
86 MongoDB
87 Lodash
91 CORS
105 N-API
108 Require