Gruntfile.js 3.6 KB

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