Gruntfile.ts 3.3 KB

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