JJ Allaire | efa6ad4 | 2016-01-30 13:12:05 -0500 | [diff] [blame] | 1 | /* global module:false */ |
| 2 | module.exports = function(grunt) { |
| 3 | var port = grunt.option('port') || 8000; |
| 4 | var base = grunt.option('base') || '.'; |
| 5 | |
| 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) 2015 Hakim El Hattab, http://hakim.se\n' + |
| 17 | ' */' |
| 18 | }, |
| 19 | |
| 20 | qunit: { |
| 21 | files: [ 'test/*.html' ] |
| 22 | }, |
| 23 | |
| 24 | uglify: { |
| 25 | options: { |
| 26 | banner: '<%= meta.banner %>\n' |
| 27 | }, |
| 28 | build: { |
| 29 | src: 'js/reveal.js', |
| 30 | dest: 'js/reveal.min.js' |
| 31 | } |
| 32 | }, |
| 33 | |
| 34 | sass: { |
| 35 | core: { |
| 36 | files: { |
| 37 | 'css/reveal.css': 'css/reveal.scss', |
| 38 | } |
| 39 | }, |
| 40 | themes: { |
| 41 | files: [ |
| 42 | { |
| 43 | expand: true, |
| 44 | cwd: 'css/theme/source', |
| 45 | src: ['*.scss'], |
| 46 | dest: 'css/theme', |
| 47 | ext: '.css' |
| 48 | } |
| 49 | ] |
| 50 | } |
| 51 | }, |
| 52 | |
| 53 | autoprefixer: { |
| 54 | dist: { |
| 55 | src: 'css/reveal.css' |
| 56 | } |
| 57 | }, |
| 58 | |
| 59 | cssmin: { |
| 60 | compress: { |
| 61 | files: { |
| 62 | 'css/reveal.min.css': [ 'css/reveal.css' ] |
| 63 | } |
| 64 | } |
| 65 | }, |
| 66 | |
| 67 | jshint: { |
| 68 | options: { |
| 69 | curly: false, |
| 70 | eqeqeq: true, |
| 71 | immed: true, |
| 72 | latedef: true, |
| 73 | newcap: true, |
| 74 | noarg: true, |
| 75 | sub: true, |
| 76 | undef: true, |
| 77 | eqnull: true, |
| 78 | browser: true, |
| 79 | expr: 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 | |
| 92 | connect: { |
| 93 | server: { |
| 94 | options: { |
| 95 | port: port, |
| 96 | base: base, |
| 97 | livereload: true, |
| 98 | open: true |
| 99 | } |
| 100 | } |
| 101 | }, |
| 102 | |
| 103 | zip: { |
| 104 | 'reveal-js-presentation.zip': [ |
| 105 | 'index.html', |
| 106 | 'css/**', |
| 107 | 'js/**', |
| 108 | 'lib/**', |
| 109 | 'images/**', |
| 110 | 'plugin/**', |
| 111 | '**.md' |
| 112 | ] |
| 113 | }, |
| 114 | |
| 115 | watch: { |
| 116 | options: { |
| 117 | livereload: true |
| 118 | }, |
| 119 | js: { |
| 120 | files: [ 'Gruntfile.js', 'js/reveal.js' ], |
| 121 | tasks: 'js' |
| 122 | }, |
| 123 | theme: { |
| 124 | files: [ 'css/theme/source/*.scss', 'css/theme/template/*.scss' ], |
| 125 | tasks: 'css-themes' |
| 126 | }, |
| 127 | css: { |
| 128 | files: [ 'css/reveal.scss' ], |
| 129 | tasks: 'css-core' |
| 130 | }, |
| 131 | html: { |
| 132 | files: [ 'index.html'] |
| 133 | }, |
| 134 | markdown: { |
| 135 | files: [ './*.md' ] |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | }); |
| 140 | |
| 141 | // Dependencies |
| 142 | grunt.loadNpmTasks( 'grunt-contrib-qunit' ); |
| 143 | grunt.loadNpmTasks( 'grunt-contrib-jshint' ); |
| 144 | grunt.loadNpmTasks( 'grunt-contrib-cssmin' ); |
| 145 | grunt.loadNpmTasks( 'grunt-contrib-uglify' ); |
| 146 | grunt.loadNpmTasks( 'grunt-contrib-watch' ); |
| 147 | grunt.loadNpmTasks( 'grunt-sass' ); |
| 148 | grunt.loadNpmTasks( 'grunt-contrib-connect' ); |
| 149 | grunt.loadNpmTasks( 'grunt-autoprefixer' ); |
| 150 | grunt.loadNpmTasks( 'grunt-zip' ); |
| 151 | |
| 152 | // Default task |
| 153 | grunt.registerTask( 'default', [ 'css', 'js' ] ); |
| 154 | |
| 155 | // JS task |
| 156 | grunt.registerTask( 'js', [ 'jshint', 'uglify', 'qunit' ] ); |
| 157 | |
| 158 | // Theme CSS |
| 159 | grunt.registerTask( 'css-themes', [ 'sass:themes' ] ); |
| 160 | |
| 161 | // Core framework CSS |
| 162 | grunt.registerTask( 'css-core', [ 'sass:core', 'autoprefixer', 'cssmin' ] ); |
| 163 | |
| 164 | // All CSS |
| 165 | grunt.registerTask( 'css', [ 'sass', 'autoprefixer', 'cssmin' ] ); |
| 166 | |
| 167 | // Package presentation to archive |
| 168 | grunt.registerTask( 'package', [ 'default', 'zip' ] ); |
| 169 | |
| 170 | // Serve presentation locally |
| 171 | grunt.registerTask( 'serve', [ 'connect', 'watch' ] ); |
| 172 | |
| 173 | // Run tests |
| 174 | grunt.registerTask( 'test', [ 'jshint', 'qunit' ] ); |
| 175 | |
| 176 | }; |