Skip to content

Instantly share code, notes, and snippets.

@thomasdegry
Created June 18, 2013 14:50
Show Gist options
  • Save thomasdegry/5806002 to your computer and use it in GitHub Desktop.
Save thomasdegry/5806002 to your computer and use it in GitHub Desktop.
var jspaths = ['webroot/js-dev/classes/**.js','webroot/js-dev/helpers.js','webroot/js-dev/main.js'];
var csspaths = ["webroot/sass/*.scss", "webroot/sass/partials/*.scss"];
var templatepaths = [];
var concatpaths = [].concat(jspaths);
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
banner: "(function(){\n\n",
footer: "\n\n})();",
separator: '\n\n'
},
dist: {
src: concatpaths,
dest: 'webroot/js/main.js'
}
},
watch: {
scripts:{
files: jspaths,
tasks: ['jshint','handlebars','concat','clean']
},
css:{
files: csspaths,
tasks:['compass:development']
}
},
uglify: {
default: {
options: {
wrap: true
},
files: {
'out/js/main.js': concatpaths
}
}
},
compass: {
development: {
options: {
sassDir: 'webroot/sass',
cssDir: 'webroot/css',
environment: 'development'
}
},
production: {
options: {
sassDir: 'webroot/sass',
cssDir: 'out/css',
environment: 'production',
outputStyle: 'compressed',
force: true
}
}
},
copy: {
production: {
files: [
{
expand: true,
cwd: 'src/',
src: ['index.html','images/*','js/vendor/*'],
dest: 'out/'
}
]
}
},
handlebars: {
compile: {
options: {
namespace: "tpl",
processName: function(filePath) {
var pieces = filePath.split("/");
return pieces[pieces.length - 1].split(".")[0];
},
partialsUseNamespace: true
},
files: {
"src/js/templates.js": templatepaths
}
}
},
jshint:{
default:{
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
noarg: true,
sub: true,
undef: true,
eqnull: true,
browser: true,
noempty: true,
trailing: true,
globals:{
$: true,
console:true,
Handlebars:true,
tpl:true,
_:true,
bean:true
},
},
files:{
src: jspaths
}
}
},
clean: ['src/js/templates.js'],
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['jshint','concat','compass:development','clean','watch']);
grunt.registerTask('production', ['jshint','uglify','compass:production','copy:production']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment