Skip to content

Instantly share code, notes, and snippets.

@andymcfee
Created August 15, 2013 12:38
Show Gist options
  • Save andymcfee/6240513 to your computer and use it in GitHub Desktop.
Save andymcfee/6240513 to your computer and use it in GitHub Desktop.
Sample Gruntfile for personal reference
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';'
},
// Target(s)
dist: {
// Compact Format
// src: ['src/**/*.js'],
// dest: 'dist/<%= pkg.name %>.js'
// Files Object Format
// files: {
// 'dist/<%= pkg.name %>.js': ['src/**/*.js'],
// 'dist/plugins.js': ['src/**/*.js']
// }
// Files Array Format
files: [
{ src: ['src/**/*.js'], dest: 'dist/<%= pkg.name %>.js'},
{ src: ['plugins/*.js'], dest: 'dist/plugins.js'}
]
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
qunit: {
files: ['test/**/*.html']
},
jshint: {
files: ['gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
options: {
// options here to override JSHint defaults
globals: {
jQuery: true,
console: true,
module: true,
document: true
}
}
},
watch: {
files: ['<%= jshint.files %>'],
tasks: ['jshint', 'qunit']
}
});
// Load Plugins
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-concat');
// Task Lists
grunt.registerTask('test', ['jshint']);
grunt.registerTask('default', ['jshint', 'uglify']);
};
{
"name": "project-name",
"version": "0.1.0",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-nodeunit": "~0.2.0",
"grunt-contrib-uglify": "~0.2.2",
"grunt-jekyll": "~0.3.9",
"grunt-contrib-concat": "~0.3.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment