animate.css/Gruntfile.js

80 lines
1.8 KiB
JavaScript
Raw Permalink Normal View History

module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
2014-02-23 23:55:37 +01:00
var concatAnim;
grunt.initConfig({
2014-02-23 23:55:37 +01:00
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
2014-02-23 23:55:37 +01:00
src: [ 'source/_base.css', 'source/**/*.css' ], // _base.css required for .animated helper class
dest: 'animate.css'
}
},
2014-02-23 23:55:37 +01:00
autoprefixer: { // https://github.com/nDmitry/grunt-autoprefixer
options: {
browsers: ['last 2 versions', 'bb 10']
},
no_dest: {
2014-02-23 23:55:37 +01:00
src: 'animate.css' // output file
}
},
cssmin: {
minify: {
src: ['animate.css'],
dest: 'animate.min.css',
2014-02-23 23:55:37 +01:00
}
},
watch: {
css: {
2014-02-23 23:55:37 +01:00
files: [ 'source/**/*', 'animate-config.json' ],
tasks: ['default']
}
}
});
2014-02-23 23:55:37 +01:00
// fuction to perform custom task
concatAnim = function () {
2014-02-23 23:55:37 +01:00
var categories = grunt.file.readJSON('animate-config.json'),
category, files, file,
target = [ 'source/_base.css' ],
count = 0;
2014-02-23 23:55:37 +01:00
for ( category in categories ) {
if ( categories.hasOwnProperty(category) ) {
files = categories[category]
for (file in files) {
if ( files.hasOwnProperty(file) && files[file] ) {
target.push('source/' + category + '/' + file + '.css');
count += 1;
}
}
}
}
if (!count) {
2014-02-23 23:55:37 +01:00
grunt.log.writeln('No animations activated.');
} else {
grunt.log.writeln(count + (count > 1 ? ' animations' : ' animation') + ' activated.');
}
2014-02-23 23:55:37 +01:00
grunt.config('concat', { 'animate.css': target });
grunt.task.run('concat');
};
// register task
grunt.registerTask('concat-anim', 'Concatenates activated animations', concatAnim); // custom task
grunt.registerTask('default', ['concat-anim', 'autoprefixer', 'cssmin']);
grunt.registerTask('dev', ['watch']);
};