Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Gruntfile template. Includes lint, concat, uglify and watch as well as growl notifications of errors and warnings (requires npm growl package to be installed).
module.exports = function(grunt) {
var defaultTasks = ['jshint', 'concat', 'uglify']; // used for watch as well
var files = [ /* your source files */ ];
grunt.initConfig({
jshint: {
all: files.concat(['Gruntfile.js'])
},
concat: {
all: {
src: files,
dest: 'project.all.js',
}
},
uglify: {
all: {
files: {
'project.min.js': files
}
}
},
watch: {
all: {
files: files,
tasks: defaultTasks,
options: {
debounceDelay: 250
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', defaultTasks);
var growl = require('growl');
['warn', 'fatal'].forEach(function(level) {
grunt.util.hooker.hook(grunt.fail, level, function(opt) {
growl(opt.name, {
title: opt.message,
image: 'Console'
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment