Gruntfile.js 3.7 KB

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