Skip to content

Instantly share code, notes, and snippets.

@carmichaelize
Created February 28, 2015 09:40
Show Gist options
  • Save carmichaelize/4a7816db13243a6860e2 to your computer and use it in GitHub Desktop.
Save carmichaelize/4a7816db13243a6860e2 to your computer and use it in GitHub Desktop.
Grunt Boilerplate
//$ npm install -g grunt-cli
//
//$ npm install grunt-contrib-concat --save-dev
//$ npm install grunt-contrib-uglify --save-dev
//$ npm install grunt-contrib-cssmin --save-dev
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//Concat Files
concat: {
dist: {
src: [
//'js/*.js' // All JS in the libs folder
'js/plugins.js',
'js/scripts.js'
],
dest: 'dist/<%= pkg.name %>.js'
},
css: {
src: [
'css/*.css'
],
dest: 'dist/<%= pkg.name %>.css'
}
},
//Minify JS
uglify: {
options: {
mangle: false,
banner: '/*! <%= grunt.template.today("dd-mm-yyyy h:MM:ss") %> */\n'
},
dist: {
files: {
'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
}
}
},
//Minify CSS
cssmin: {
add_banner: {
options: {
banner: '/*! <%= grunt.template.today("dd-mm-yyyy h:MM:ss") %> */\n'
},
files: {
'dist/<%= pkg.name %>-min.css': ['<%= concat.css.dest %>']
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.registerTask('default', ['concat', 'uglify', 'cssmin']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment