Skip to content

Instantly share code, notes, and snippets.

@edwardhotchkiss
Last active December 15, 2015 05:09
Show Gist options
  • Save edwardhotchkiss/5206460 to your computer and use it in GitHub Desktop.
Save edwardhotchkiss/5206460 to your computer and use it in GitHub Desktop.
Gruntfile for a project using .js and .less - for clarity sake we'll pretend that everything for the fat-client is in /src/app.js
/*!
* @description GRUNT! (.js)
*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> v<%= pkg.version %>, <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'public/js/app.js',
dest: 'public/js/app.min.js'
}
},
jshint: {
options: {
browser: true,
globals: {
jQuery: true
}
},
all: {
files: {
src: ['public/js/src/**/*.js']
}
}
},
concat: {
options: {
},
dist: {
src: [
'public/js/vendor/jquery-1.9.1.js',
'public/js/vendor/prettify.js',
'public/js/vendor/lang-css.js',
'public/js/vendor/jquery.transit.min.js',
'public/js/vendor/jquery.notify.js',
'public/js/vendor/underscore.js',
'public/js/vendor/handlebars-1.0.0.beta.6.js',
'public/js/vendor/backbone-v1.0.0.js',
'public/js/vendor/backbone.localStorage-1.1.0.js',
'public/js/vendor/backbone.marionette-v1.0.0-rc6.js',
'public/js/vendor/backbone.wreqr.js',
'public/js/vendor/backbone.babysitter-v0.0.5.js',
'public/js/src/helpers/HandlebarsHelpers.js',
'public/js/src/app.js',
'public/js/src/models/**/*.js',
'public/js/src/collections/**/*.js',
'public/js/src/views/**/*.js',
'public/js/src/routers/Router.js',
'public/js/src/initialize.js'
],
dest: 'public/js/app.js'
}
},
less: {
development: {
options: {
paths: ['public/less'],
yuicompress: false
},
files: {
'public/css/app.css':'public/less/index.less'
}
}
},
cssmin: {
compress: {
files: {
'public/css/app.min.css': ['public/css/app.css']
}
}
},
watch: {
scripts: {
files: ['Gruntfile.js','public/js/src/**/*.js','public/js/vendor/**/*.js'],
tasks: ['jshint','concat','less'],
},
less: {
files: 'public/less/**/*.less',
tasks: ['less'],
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('deploy', ['jshint','concat','uglify','less','cssmin']);
grunt.registerTask('default', ['jshint','concat','less','watch']);
};
/* EOF */

usage

developing:

$ grunt

deploy:

$ grunt deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment