Created
April 27, 2013 23:02
-
-
Save ibspoof/5475095 to your computer and use it in GitHub Desktop.
Grunt 0.4 Gruntfile.js Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global $:false */ | |
var path = require('path'); | |
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet; | |
var folderMount = function folderMount(connect, point) | |
{ | |
return connect.static(path.resolve(point)); | |
}; | |
module.exports = function (grunt) | |
{ | |
'use strict'; | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: '<json:package.json>', | |
meta: { | |
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %>\n' + '<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + ' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' | |
}, | |
less: { | |
development: { | |
files: { | |
"assets/css/app.css": "assets/less/app.less", | |
"assets/css/bootstrap.css": "assets/less/init.less" | |
} | |
}, | |
production: { | |
options: { | |
yuicompress: true | |
}, | |
files: { | |
"assets/css/app.min.css": "assets/less/app.less", | |
"assets/css/bootstrap.min.css": "assets/less/init.less" | |
} | |
} | |
}, | |
concat: { | |
dist: { | |
src: ['assets/js/bootstrap.js', 'assets/js/application.js'], | |
dest: 'assets/js/app.js' | |
} | |
}, | |
uglify: { | |
options: { | |
mangle: false | |
}, | |
my_target: { | |
files: { | |
'assets/js/app.min.js': ['assets/js/bootstrap.js', 'assets/js/application.js'] | |
} | |
} | |
}, | |
jshint: { | |
options: { | |
curly: true, | |
eqeqeq: true, | |
eqnull: true, | |
browser: true, | |
globals: { | |
jQuery: true, | |
module: true | |
} | |
}, | |
all: ['Gruntfile.js', 'assets/js/application.js'] | |
}, | |
livereload: { | |
// add ability to change port or other options here | |
}, | |
connect: { | |
livereload: { | |
options: { | |
port: 9001, // port server will be listening on | |
base: './', | |
middleware: function (connect, options) | |
{ | |
return [lrSnippet, folderMount(connect, options.base)]; | |
} | |
} | |
} | |
}, | |
regarde: { | |
js: { | |
files: 'assets/**/*.js', | |
tasks: ['livereload'] | |
}, | |
html: { | |
files: '*.html', | |
tasks: ['livereload'] | |
}, | |
css: { | |
files: 'assets/less/*.less', | |
events: true, | |
tasks: ['less:development', 'livereload'] | |
} | |
}, | |
csslint: { | |
options: { | |
import: false | |
}, | |
src: ['assets/css/app.css'] | |
} | |
}); | |
// load Grunt Plugins | |
grunt.loadNpmTasks('grunt-contrib-connect'); | |
grunt.loadNpmTasks('grunt-contrib-livereload'); | |
grunt.loadNpmTasks('grunt-contrib-less'); | |
grunt.loadNpmTasks('grunt-contrib-uglify'); | |
grunt.loadNpmTasks('grunt-contrib-csslint'); | |
grunt.loadNpmTasks('grunt-contrib-jshint'); | |
grunt.loadNpmTasks('grunt-regarde'); | |
// default | |
grunt.registerTask('default', ['less:development', 'jshint', 'csslint']); | |
// enable live reload features | |
grunt.registerTask('live', ['livereload-start', 'connect', 'regarde', 'jshint', 'less:development', 'csslint']); | |
// compress both css and javascript for production | |
grunt.registerTask('production', ['less:production', 'uglify']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment