Gruntfile.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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. screwIE8: false
  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. dist: '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. }
  92. }
  93. },
  94. zip: {
  95. bundle: {
  96. src: [
  97. 'index.html',
  98. 'css/**',
  99. 'js/**',
  100. 'lib/**',
  101. 'images/**',
  102. 'plugin/**',
  103. '**.md'
  104. ],
  105. dest: 'reveal-js-presentation.zip'
  106. }
  107. },
  108. watch: {
  109. js: {
  110. files: [ 'Gruntfile.js', 'js/reveal.js' ],
  111. tasks: 'js'
  112. },
  113. theme: {
  114. files: [
  115. 'css/theme/source/*.sass',
  116. 'css/theme/source/*.scss',
  117. 'css/theme/template/*.sass',
  118. 'css/theme/template/*.scss'
  119. ],
  120. tasks: 'css-themes'
  121. },
  122. css: {
  123. files: [ 'css/reveal.scss' ],
  124. tasks: 'css-core'
  125. },
  126. html: {
  127. files: root.map(path => path + '/*.html')
  128. },
  129. markdown: {
  130. files: root.map(path => path + '/*.md')
  131. },
  132. options: {
  133. livereload: true
  134. }
  135. },
  136. retire: {
  137. js: [ 'js/reveal.js', 'lib/js/*.js', 'plugin/**/*.js' ],
  138. node: [ '.' ]
  139. }
  140. });
  141. // Dependencies
  142. grunt.loadNpmTasks( 'grunt-contrib-connect' );
  143. grunt.loadNpmTasks( 'grunt-contrib-cssmin' );
  144. grunt.loadNpmTasks( 'grunt-contrib-jshint' );
  145. grunt.loadNpmTasks( 'grunt-contrib-qunit' );
  146. grunt.loadNpmTasks( 'grunt-contrib-uglify' );
  147. grunt.loadNpmTasks( 'grunt-contrib-watch' );
  148. grunt.loadNpmTasks( 'grunt-autoprefixer' );
  149. grunt.loadNpmTasks( 'grunt-retire' );
  150. grunt.loadNpmTasks( 'grunt-sass' );
  151. grunt.loadNpmTasks( 'grunt-zip' );
  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. };