presentations

Presentations
Log | Files | Refs

gruntfile.js (3485B)


      1 const sass = require('node-sass');
      2 
      3 module.exports = grunt => {
      4 
      5 	require('load-grunt-tasks')(grunt);
      6 
      7 	let port = grunt.option('port') || 8000;
      8 	let root = grunt.option('root') || '.';
      9 
     10 	if (!Array.isArray(root)) root = [root];
     11 
     12 	// Project configuration
     13 	grunt.initConfig({
     14 		pkg: grunt.file.readJSON('package.json'),
     15 		meta: {
     16 			banner:
     17 				'/*!\n' +
     18 				' * reveal.js <%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd, HH:MM") %>)\n' +
     19 				' * http://revealjs.com\n' +
     20 				' * MIT licensed\n' +
     21 				' *\n' +
     22 				' * Copyright (C) 2019 Hakim El Hattab, http://hakim.se\n' +
     23 				' */'
     24 		},
     25 
     26 		qunit: {
     27 			files: [ 'test/*.html' ]
     28 		},
     29 
     30 		uglify: {
     31 			options: {
     32 				banner: '<%= meta.banner %>\n',
     33 				ie8: true
     34 			},
     35 			build: {
     36 				src: 'js/reveal.js',
     37 				dest: 'js/reveal.min.js'
     38 			}
     39 		},
     40 
     41 		sass: {
     42 			options: {
     43 				implementation: sass,
     44 				sourceMap: false
     45 			},
     46 			core: {
     47 				src: 'css/reveal.scss',
     48 				dest: 'css/reveal.css'
     49 			},
     50 			themes: {
     51 				expand: true,
     52 				cwd: 'css/theme/source',
     53 				src: ['*.sass', '*.scss'],
     54 				dest: 'css/theme',
     55 				ext: '.css'
     56 			}
     57 		},
     58 
     59 		autoprefixer: {
     60 			core: {
     61 				src: 'css/reveal.css'
     62 			}
     63 		},
     64 
     65 		cssmin: {
     66 			options: {
     67 				compatibility: 'ie9'
     68 			},
     69 			compress: {
     70 				src: 'css/reveal.css',
     71 				dest: 'css/reveal.min.css'
     72 			}
     73 		},
     74 
     75 		jshint: {
     76 			options: {
     77 				curly: false,
     78 				eqeqeq: true,
     79 				immed: true,
     80 				esnext: true,
     81 				latedef: 'nofunc',
     82 				newcap: true,
     83 				noarg: true,
     84 				sub: true,
     85 				undef: true,
     86 				eqnull: true,
     87 				browser: true,
     88 				expr: true,
     89 				loopfunc: true,
     90 				globals: {
     91 					head: false,
     92 					module: false,
     93 					console: false,
     94 					unescape: false,
     95 					define: false,
     96 					exports: false,
     97 					require: false
     98 				}
     99 			},
    100 			files: [ 'gruntfile.js', 'js/reveal.js' ]
    101 		},
    102 
    103 		connect: {
    104 			server: {
    105 				options: {
    106 					port: port,
    107 					base: root,
    108 					livereload: true,
    109 					open: true,
    110 					useAvailablePort: true
    111 				}
    112 			}
    113 		},
    114 
    115 		zip: {
    116 			bundle: {
    117 				src: [
    118 					'index.html',
    119 					'css/**',
    120 					'js/**',
    121 					'lib/**',
    122 					'images/**',
    123 					'plugin/**',
    124 					'**.md'
    125 				],
    126 				dest: 'reveal-js-presentation.zip'
    127 			}
    128 		},
    129 
    130 		watch: {
    131 			js: {
    132 				files: [ 'gruntfile.js', 'js/reveal.js' ],
    133 				tasks: 'js'
    134 			},
    135 			theme: {
    136 				files: [
    137 					'css/theme/source/*.sass',
    138 					'css/theme/source/*.scss',
    139 					'css/theme/template/*.sass',
    140 					'css/theme/template/*.scss'
    141 				],
    142 				tasks: 'css-themes'
    143 			},
    144 			css: {
    145 				files: [ 'css/reveal.scss' ],
    146 				tasks: 'css-core'
    147 			},
    148 			test: {
    149 				files: [ 'test/*.html' ],
    150 				tasks: 'test'
    151 			},
    152 			html: {
    153 				files: root.map(path => path + '/*.html')
    154 			},
    155 			markdown: {
    156 				files: root.map(path => path + '/*.md')
    157 			},
    158 			options: {
    159 				livereload: true
    160 			}
    161 		}
    162 
    163 	});
    164 
    165 	grunt.loadNpmTasks('grunt-contrib-clean');
    166 	grunt.loadNpmTasks('grunt-contrib-nodeunit');
    167 
    168 	// Default task
    169 	grunt.registerTask( 'default', [ 'css', 'js' ] );
    170 
    171 	// JS task
    172 	grunt.registerTask( 'js', [ 'jshint', 'uglify', 'qunit' ] );
    173 
    174 	// Theme CSS
    175 	grunt.registerTask( 'css-themes', [ 'sass:themes' ] );
    176 
    177 	// Core framework CSS
    178 	grunt.registerTask( 'css-core', [ 'sass:core', 'autoprefixer', 'cssmin' ] );
    179 
    180 	// All CSS
    181 	grunt.registerTask( 'css', [ 'sass', 'autoprefixer', 'cssmin' ] );
    182 
    183 	// Package presentation to archive
    184 	grunt.registerTask( 'package', [ 'default', 'zip' ] );
    185 
    186 	// Serve presentation locally
    187 	grunt.registerTask( 'serve', [ 'connect', 'watch' ] );
    188 
    189 	// Run tests
    190 	grunt.registerTask( 'test', [ 'jshint', 'qunit' ] );
    191 
    192 };