Gruntfile.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. globals: {
  74. head: false,
  75. module: false,
  76. console: false,
  77. unescape: false,
  78. define: false,
  79. exports: false
  80. }
  81. },
  82. files: [ 'Gruntfile.js', 'js/reveal.js' ]
  83. },
  84. connect: {
  85. server: {
  86. options: {
  87. port: port,
  88. base: root,
  89. livereload: true,
  90. open: true,
  91. useAvailablePort: true
  92. }
  93. }
  94. },
  95. zip: {
  96. bundle: {
  97. src: [
  98. 'index.html',
  99. 'css/**',
  100. 'js/**',
  101. 'lib/**',
  102. 'images/**',
  103. 'plugin/**',
  104. '**.md'
  105. ],
  106. dest: 'reveal-js-presentation.zip'
  107. }
  108. },
  109. watch: {
  110. js: {
  111. files: [ 'Gruntfile.js', 'js/reveal.js' ],
  112. tasks: 'js'
  113. },
  114. theme: {
  115. files: [
  116. 'css/theme/source/*.sass',
  117. 'css/theme/source/*.scss',
  118. 'css/theme/template/*.sass',
  119. 'css/theme/template/*.scss'
  120. ],
  121. tasks: 'css-themes'
  122. },
  123. css: {
  124. files: [ 'css/reveal.scss' ],
  125. tasks: 'css-core'
  126. },
  127. html: {
  128. files: root.map(path => path + '/*.html')
  129. },
  130. markdown: {
  131. files: root.map(path => path + '/*.md')
  132. },
  133. options: {
  134. livereload: true
  135. }
  136. },
  137. retire: {
  138. js: [ 'js/reveal.js', 'lib/js/*.js', 'plugin/**/*.js' ],
  139. node: [ '.' ]
  140. }
  141. });
  142. // Dependencies
  143. grunt.loadNpmTasks( 'grunt-contrib-connect' );
  144. grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
  145. grunt.loadNpmTasks( 'grunt-contrib-jshint' );
  146. grunt.loadNpmTasks( 'grunt-contrib-qunit' );
  147. grunt.loadNpmTasks( 'grunt-contrib-uglify' );
  148. grunt.loadNpmTasks( 'grunt-contrib-watch' );
  149. grunt.loadNpmTasks( 'grunt-autoprefixer' );
  150. grunt.loadNpmTasks( 'grunt-retire' );
  151. grunt.loadNpmTasks( 'grunt-sass' );
  152. grunt.loadNpmTasks( 'grunt-zip' );
  153. // Default task
  154. grunt.registerTask( 'default', [ 'css', 'js' ] );
  155. // JS task
  156. grunt.registerTask( 'js', [ 'jshint', 'uglify', 'qunit' ] );
  157. // Theme CSS
  158. grunt.registerTask( 'css-themes', [ 'sass:themes' ] );
  159. // Core framework CSS
  160. grunt.registerTask( 'css-core', [ 'sass:core', 'autoprefixer', 'cssmin' ] );
  161. // All CSS
  162. grunt.registerTask( 'css', [ 'sass', 'autoprefixer', 'cssmin' ] );
  163. // Package presentation to archive
  164. grunt.registerTask( 'package', [ 'default', 'zip' ] );
  165. // Serve presentation locally
  166. grunt.registerTask( 'serve', [ 'connect', 'watch' ] );
  167. // Run tests
  168. grunt.registerTask( 'test', [ 'jshint', 'qunit' ] );
  169. };