Created
September 11, 2013 09:34
-
-
Save Couto/6521391 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/*jshint node:true*/ | |
module.exports = function (grunt) { | |
'use strict'; | |
grunt.initConfig({ | |
files: { | |
http : '/', | |
html: '../application/views', | |
css : 'stylesheets', | |
sass : 'sass', | |
imgs : 'images', | |
js : 'scripts', | |
hbs: 'scripts/app/library/templates/', | |
output: { | |
html: '../application/views', | |
css : 'stylesheets', | |
imgs : 'images', | |
js : 'scripts', | |
hbs: 'scripts/app/library/templates/compiled' | |
} | |
}, | |
jshint: { | |
options: { | |
jshintrc: '.jshintrc' | |
}, | |
src: ['<%= files.js %>/**/*.js', '!**/third_party/**'] | |
}, | |
groundskeeper: { | |
ie: { | |
expand: true, | |
cwd: '<%= files.js %>', | |
src: ['**/*.js', '!**/plugins/**'], | |
dest: '<%= files.output.js %>', | |
options: { | |
pragmas: ['development', 'debugging', 'validation'] | |
} | |
}, | |
prod: { | |
expand: true, | |
cwd: '<%= files.js %>', | |
src: ['**/*.js', '!**/plugins/**'], | |
dest: '<%= files.output.js %>', | |
options: { | |
pragmas: ['development', 'debugging', 'validation'] | |
} | |
} | |
}, | |
htmlmin: { | |
prod: { | |
expand: true, | |
cwd: '<%= files.html %>', | |
src: ['**/*.php'], | |
dest: '<%= files.output.html %>', | |
options: { | |
removeComments: true, | |
removeCDATASectionsFromCDATA: true, | |
collapseWhitespace: true, | |
removeRedundantAttributes: true, | |
removeEmptyAttributes: true | |
} | |
} | |
}, | |
cssmin: { | |
prod: { | |
expand: true, | |
cwd: '<%= files.output.css %>', | |
src: ['**/*.css'], | |
dest: '<%= files.output.css %>', | |
options: { | |
banner: false, | |
keepSpecialComments: 0, | |
report: 'gzip', | |
removeRedundantAttributes: true, | |
removeEmptyAttributes: true | |
} | |
} | |
}, | |
imagemin: { | |
prod: { | |
options: { | |
trials: 7, | |
progressive: true | |
}, | |
expand: true, | |
cwd: '<%= files.imgs %>', | |
src: ['**/**/*.jpg', '**/**/*.png', '**/**/*.gif'], | |
dest: '<%= files.output.imgs %>/' | |
} | |
}, | |
handlebars: { | |
prod: { | |
options: { | |
processContent: function (content) { | |
return content | |
.replace(/^[\x20\t]+/mg, '') | |
.replace(/[\x20\t]+$/mg, '') | |
.replace(/^[\r\n]+/, '') | |
.replace(/[\r\n]*$/, '\n'); | |
}, | |
processName: function (filePath) { | |
return filePath | |
.replace('scripts/app/library/templates/', '') | |
.replace('.handlebars', ''); | |
}, | |
namespace: 'Handlebars.templates' | |
}, | |
expand: true, | |
cwd: '<%= files.hbs %>', | |
src: ['**/*.handlebars'], | |
dest: '<%= files.output.hbs %>', | |
ext: '.js' | |
} | |
}, | |
uglify: { | |
hbs: { | |
options: { report: 'gzip' }, | |
expand: true, | |
cwd: '<%= files.output.hbs %>', | |
src: ['**/*.js'], | |
dest: '<%= files.output.hbs %>' | |
}, | |
js: { | |
options: { | |
compress: true, | |
mangle: true, | |
report: 'gzip', | |
preserveComments: 'false' | |
}, | |
expand: true, | |
cwd: '<%= files.js %>', | |
src: ['**/*.js', '!**/**/fineuploader_min.js'], | |
dest: '<%= files.output.js %>' | |
} | |
}, | |
compass: { | |
dev: { | |
'http_path' : '<%= files.http_path %>', | |
'css_dir' : '<%= files.css %>', | |
'sass_dir' : '<%= files.sass %>', | |
'images_dir' : '<%= files.imgs %>', | |
'javascripts_dir' : '<%= files.js %>', | |
'environment': 'development' | |
}, | |
prod: { | |
'http_path' : '<%= files.http_path %>', | |
'css_dir' : '<%= files.output.css %>', | |
'sass_dir' : '<%= files.sass %>', | |
'images_dir' : '<%= files.imgs %>', | |
'javascripts_dir' : '<%= files.js %>', | |
'enviroment': 'production', | |
'outputStyle': 'compressed' | |
} | |
}, | |
watch: { | |
sass: { | |
files: '<%= files.sass %>/**/*.scss', | |
tasks: ['compass:dev'] | |
}, | |
jshint: { | |
files: '<%= files.js %>/**/*.js', | |
tasks: ['jshint'] | |
}, | |
dev: { | |
files: ['<%= files.sass %>/**/*.scss', '<%= files.js %>/**/*.js'], | |
tasks: ['compass:dev', 'jshint'] | |
} | |
}, | |
clean: { | |
css: ['<%= files.output.css %>'], | |
hbs: ['<%= files.output.hbs %>'], | |
imgs: ['<%= files.output.imgs %>'] // dev purposes only | |
}, | |
compress: { | |
build: { | |
options: { | |
archive: 'resources.tar.gz', | |
mode: 'tgz' | |
}, | |
files: [{ | |
src: ['./**/*'], | |
dest: '.' | |
}] | |
} | |
} | |
}); | |
// Load tasks | |
Object | |
.keys(require('./package.json').devDependencies) | |
.forEach(function (key) { | |
return (/^grunt-/).test(key) && grunt.loadNpmTasks(key); | |
}); | |
grunt.registerTask('css', ['clean:css', 'compass:prod', 'cssmin:prod']); | |
grunt.registerTask('hbs', ['clean:hbs', 'handlebars:prod', 'uglify:hbs']); | |
grunt.registerTask('js', ['groundskeeper:prod', 'uglify:js']); | |
grunt.registerTask('img', [ 'imagemin:prod']); | |
grunt.registerTask('build', ['css', 'hbs', 'js', 'img', 'compress']); | |
grunt.registerTask('default', ['watch:sass']); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment