Gruntfile.js 3.8 KB

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