Gruntfile.js 3.3 KB

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