Skip to content

Instantly share code, notes, and snippets.

@alliejones
Last active December 15, 2015 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alliejones/5306809 to your computer and use it in GitHub Desktop.
Save alliejones/5306809 to your computer and use it in GitHub Desktop.
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