custom grunt tasks are basically node modules that you can publish to the npm registry. Take a look at the existing ones and the documentation on how to build them here:
http://gruntjs.com/api/grunt.task
basically you just do something like this:
module.exports = function (grunt) {
To make your work easier, you should use grunt-init with grunt-init-gruntplugin , which basically installs everything for you!
If you do not want to publish your module before npm, you can install it in your project from the git repository (for example, using github):
$ npm install git+https:
the -save option saves it automatically as a dependency in package.json projects.
if you just want to include one js file in your project, put it in the directory of your choice (here I use grunt-tasks) and include it in your grunt file:
grunt.loadTasks("./grunt-tasks");
which will try to include every js file in this directory as grunt jobs.
hereandnow78
source share