Gruntfile.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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://revealjs.com\n' +
  14. ' * MIT licensed\n' +
  15. ' *\n' +
  16. ' * Copyright (C) 2018 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. ie8: true
  26. },
  27. build: {
  28. src: 'js/reveal.js',
  29. dest: 'js/reveal.min.js'
  30. }
  31. },
  32. sass: {
  33. core: {
  34. src: 'css/reveal.scss',
  35. dest: 'css/reveal.css'
  36. },
  37. themes: {
  38. expand: true,
  39. cwd: 'css/theme/source',
  40. src: ['*.sass', '*.scss'],
  41. dest: 'css/theme',
  42. ext: '.css'
  43. }
  44. },
  45. autoprefixer: {
  46. core: {
  47. src: 'css/reveal.css'
  48. }
  49. },
  50. cssmin: {
  51. options: {
  52. compatibility: 'ie9'
  53. },
  54. compress: {
  55. src: 'css/reveal.css',
  56. dest: 'css/reveal.min.css'
  57. }
  58. },
  59. jshint: {
  60. options: {
  61. curly: false,
  62. eqeqeq: true,
  63. immed: true,
  64. esnext: true,
  65. latedef: 'nofunc',
  66. newcap: true,
  67. noarg: true,
  68. sub: true,
  69. undef: true,
  70. eqnull: true,
  71. browser: true,
  72. expr: true,
  73. loopfunc: true,
  74. globals: {
  75. head: false,
  76. module: false,
  77. console: false,
  78. unescape: false,
  79. define: false,
  80. exports: false
  81. }
  82. },
  83. files: [ 'Gruntfile.js', 'js/reveal.js' ]
  84. },
  85. connect: {
  86. server: {
  87. options: {
  88. port: port,
  89. base: root,
  90. livereload: true,
  91. open: true,
  92. useAvailablePort: true
  93. }
  94. }
  95. },
  96. zip: {
  97. bundle: {
  98. src: [
  99. 'index.html',
  100. 'css/**',
  101. 'js/**',
  102. 'lib/**',
  103. 'images/**',
  104. 'plugin/**',
  105. '**.md'
  106. ],
  107. dest: 'reveal-js-presentation.zip'
  108. }
  109. },
  110. watch: {
  111. js: {
  112. files: [ 'Gruntfile.js', 'js/reveal.js' ],
  113. tasks: 'js'
  114. },
  115. theme: {
  116. files: [
  117. 'css/theme/source/*.sass',
  118. 'css/theme/source/*.scss',
  119. 'css/theme/template/*.sass',
  120. 'css/theme/template/*.scss'
  121. ],
  122. tasks: 'css-themes'
  123. },
  124. css: {
  125. files: [ 'css/reveal.scss' ],
  126. tasks: 'css-core'
  127. },
  128. html: {
  129. files: root.map(path => path + '/*.html')
  130. },
  131. markdown: {
  132. files: root.map(path => path + '/*.md')
  133. },
  134. options: {
  135. livereload: true
  136. }
  137. },
  138. retire: {
  139. js: [ 'js/reveal.js', 'lib/js/*.js', 'plugin/**/*.js' ],
  140. node: [ '.' ]
  141. }
  142. });
  143. // Dependencies
  144. grunt.loadNpmTasks( 'grunt-contrib-connect' );
  145. grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
  146. grunt.loadNpmTasks( 'grunt-contrib-jshint' );
  147. grunt.loadNpmTasks( 'grunt-contrib-qunit' );
  148. grunt.loadNpmTasks( 'grunt-contrib-uglify' );
  149. grunt.loadNpmTasks( 'grunt-contrib-watch' );
  150. grunt.loadNpmTasks( 'grunt-autoprefixer' );
  151. grunt.loadNpmTasks( 'grunt-retire' );
  152. grunt.loadNpmTasks( 'grunt-sass' );
  153. grunt.loadNpmTasks( 'grunt-zip' );
  154. // Default task
  155. grunt.registerTask( 'default', [ 'css', 'js' ] );
  156. // JS task
  157. grunt.registerTask( 'js', [ 'jshint', 'uglify', 'qunit' ] );
  158. // Theme CSS
  159. grunt.registerTask( 'css-themes', [ 'sass:themes' ] );
  160. // Core framework CSS
  161. grunt.registerTask( 'css-core', [ 'sass:core', 'autoprefixer', 'cssmin' ] );
  162. // All CSS
  163. grunt.registerTask( 'css', [ 'sass', 'autoprefixer', 'cssmin' ] );
  164. // Package presentation to archive
  165. grunt.registerTask( 'package', [ 'default', 'zip' ] );
  166. // Serve presentation locally
  167. grunt.registerTask( 'serve', [ 'connect', 'watch' ] );
  168. // Run tests
  169. grunt.registerTask( 'test', [ 'jshint', 'qunit' ] );
  170. };