Skip to content

Instantly share code, notes, and snippets.

@ijy
Created August 13, 2012 11:41
Show Gist options
  • Save ijy/3339904 to your computer and use it in GitHub Desktop.
Save ijy/3339904 to your computer and use it in GitHub Desktop.
grunt.js file used purely for JS concatenation & minification with a watch to automate the process. Includes multiple build targets.
/* global module:false */
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Project metadata, used by some directives, helpers and tasks.
meta: {
project: '<Project Name>',
author: "<Author>",
url: '<URL>',
banner: '/* \n' +
' * \tProduced:\t\t<%= meta.author %>\n' +
' * \tURL:\t<%= meta.url %>\n' +
' * \n' +
' * \tProject:\t\t<%= meta.title %>\n' +
' * \tBuild Date:\t\t<%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * \n' +
' */'
},
// Lists of files to be concatenated, used by the "concat" task.
concat: {
// Main site scripts
site: {
src: [
'vendor/nivo.slider.pack.js',
'vendor/sliderAccess.js',
'site.js'
],
dest: 'build/site.js'
},
// Checkout module scripts
checkout: {
src: [
'vendor/jquery-ui-custom.js',
'vendor/jquery-ui-timepicker.js',
'checkout.js'
],
dest: 'build/checkout.js'
}
},
// Lists of files to be minified with UglifyJS, used by the "min" task.
min: {
// Main site scripts
site: {
src: [
'<banner>',
'build/site.js'
],
dest: 'build/site.min.js'
},
// Checkout module scripts
checkout: {
src: [
'<banner>',
'build/checkout.js'
],
dest: 'build/checkout.min.js'
}
},
// Configuration options for the "watch" task.
watch: {
files: ['*.js'],
tasks: 'default'
}
});
// Default task.
grunt.registerTask('default', 'concat min'); // Optionally pass watch here to have it run automatically.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment