Gruntfile.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. module.exports = function(grunt) {
  2. require('load-grunt-tasks')(grunt);
  3. var concatAnim;
  4. grunt.initConfig({
  5. pkg: grunt.file.readJSON('package.json'),
  6. concat: {
  7. dist: {
  8. src: [ 'source/_base.css', 'source/**/*.css' ], // _base.css required for .animated helper class
  9. dest: 'animate.css'
  10. }
  11. },
  12. autoprefixer: { // https://github.com/nDmitry/grunt-autoprefixer
  13. options: {
  14. browsers: ['last 2 versions', 'bb 10']
  15. },
  16. no_dest: {
  17. src: 'animate.css' // output file
  18. }
  19. },
  20. cssmin: {
  21. minify: {
  22. src: ['animate.css'],
  23. dest: 'animate.min.css',
  24. }
  25. },
  26. watch: {
  27. css: {
  28. files: [ 'source/**/*', 'animate-config.json' ],
  29. tasks: ['default']
  30. }
  31. }
  32. });
  33. // fuction to perform custom task
  34. concatAnim = function () {
  35. var categories = grunt.file.readJSON('animate-config.json'),
  36. category, files, file,
  37. target = [ 'source/_base.css' ],
  38. count = 0;
  39. for ( category in categories ) {
  40. if ( categories.hasOwnProperty(category) ) {
  41. files = categories[category]
  42. for (file in files) {
  43. if ( files.hasOwnProperty(file) && files[file] ) {
  44. target.push('source/' + category + '/' + file + '.css');
  45. count += 1;
  46. }
  47. }
  48. }
  49. }
  50. if (!count) {
  51. grunt.log.writeln('No animations activated.');
  52. } else {
  53. grunt.log.writeln(count + (count > 1 ? ' animations' : ' animation') + ' activated.');
  54. }
  55. grunt.config('concat', { 'animate.css': target });
  56. grunt.task.run('concat');
  57. };
  58. // register task
  59. grunt.registerTask('concat-anim', 'Concatenates activated animations', concatAnim); // custom task
  60. grunt.registerTask('default', ['concat-anim', 'autoprefixer', 'cssmin']);
  61. grunt.registerTask('dev', ['watch']);
  62. };