Gruntfile.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* global module:false */
  2. module.exports = function(grunt) {
  3. var port = grunt.option('port') || 8000;
  4. // Project configuration
  5. grunt.initConfig({
  6. pkg: grunt.file.readJSON('package.json'),
  7. meta: {
  8. banner:
  9. '/*!\n' +
  10. ' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
  11. ' * http://lab.hakim.se/reveal-js\n' +
  12. ' * MIT licensed\n' +
  13. ' *\n' +
  14. ' * Copyright (C) 2015 Hakim El Hattab, http://hakim.se\n' +
  15. ' */'
  16. },
  17. qunit: {
  18. files: [ 'test/*.html' ]
  19. },
  20. uglify: {
  21. options: {
  22. banner: '<%= meta.banner %>\n'
  23. },
  24. build: {
  25. src: 'js/reveal.js',
  26. dest: 'js/reveal.min.js'
  27. }
  28. },
  29. sass: {
  30. core: {
  31. files: {
  32. 'css/reveal.css': 'css/reveal.scss',
  33. }
  34. },
  35. themes: {
  36. files: [
  37. {
  38. expand: true,
  39. cwd: 'css/theme/source',
  40. src: ['*.scss'],
  41. dest: 'css/theme',
  42. ext: '.css'
  43. }
  44. ]
  45. }
  46. },
  47. autoprefixer: {
  48. dist: {
  49. src: 'css/reveal.css'
  50. }
  51. },
  52. cssmin: {
  53. compress: {
  54. files: {
  55. 'css/reveal.min.css': [ 'css/reveal.css' ]
  56. }
  57. }
  58. },
  59. jshint: {
  60. options: {
  61. curly: false,
  62. eqeqeq: true,
  63. immed: true,
  64. latedef: true,
  65. newcap: true,
  66. noarg: true,
  67. sub: true,
  68. undef: true,
  69. eqnull: true,
  70. browser: true,
  71. expr: true,
  72. globals: {
  73. head: false,
  74. module: false,
  75. console: false,
  76. unescape: false,
  77. define: false,
  78. exports: false
  79. }
  80. },
  81. files: [ 'Gruntfile.js', 'js/reveal.js' ]
  82. },
  83. connect: {
  84. server: {
  85. options: {
  86. port: port,
  87. base: '.',
  88. livereload: true,
  89. open: true
  90. }
  91. }
  92. },
  93. zip: {
  94. 'reveal-js-presentation.zip': [
  95. 'index.html',
  96. 'css/**',
  97. 'js/**',
  98. 'lib/**',
  99. 'images/**',
  100. 'plugin/**'
  101. ]
  102. },
  103. watch: {
  104. options: {
  105. livereload: true
  106. },
  107. js: {
  108. files: [ 'Gruntfile.js', 'js/reveal.js' ],
  109. tasks: 'js'
  110. },
  111. theme: {
  112. files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ],
  113. tasks: 'css-themes'
  114. },
  115. css: {
  116. files: [ 'css/reveal.scss' ],
  117. tasks: 'css-core'
  118. },
  119. html: {
  120. files: [ 'index.html']
  121. }
  122. }
  123. });
  124. // Dependencies
  125. grunt.loadNpmTasks( 'grunt-contrib-qunit' );
  126. grunt.loadNpmTasks( 'grunt-contrib-jshint' );
  127. grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
  128. grunt.loadNpmTasks( 'grunt-contrib-uglify' );
  129. grunt.loadNpmTasks( 'grunt-contrib-watch' );
  130. grunt.loadNpmTasks( 'grunt-sass' );
  131. grunt.loadNpmTasks( 'grunt-contrib-connect' );
  132. grunt.loadNpmTasks( 'grunt-autoprefixer' );
  133. grunt.loadNpmTasks( 'grunt-zip' );
  134. // Default task
  135. grunt.registerTask( 'default', [ 'css', 'js' ] );
  136. // JS task
  137. grunt.registerTask( 'js', [ 'jshint', 'uglify', 'qunit' ] );
  138. // Theme CSS
  139. grunt.registerTask( 'css-themes', [ 'sass:themes' ] );
  140. // Core framework CSS
  141. grunt.registerTask( 'css-core', [ 'sass:core', 'autoprefixer', 'cssmin' ] );
  142. // All CSS
  143. grunt.registerTask( 'css', [ 'sass', 'autoprefixer', 'cssmin' ] );
  144. // Package presentation to archive
  145. grunt.registerTask( 'package', [ 'default', 'zip' ] );
  146. // Serve presentation locally
  147. grunt.registerTask( 'serve', [ 'connect', 'watch' ] );
  148. // Run tests
  149. grunt.registerTask( 'test', [ 'jshint', 'qunit' ] );
  150. };