2018-03-11 14:15:17 +01:00
|
|
|
const gulp = require('gulp')
|
2020-03-03 21:01:35 +01:00
|
|
|
const zip = require('gulp-zip')
|
|
|
|
const sass = require('gulp-sass')
|
|
|
|
const qunit = require('gulp-qunit')
|
|
|
|
const header = require('gulp-header')
|
2018-05-14 20:01:59 +02:00
|
|
|
const eslint = require('gulp-eslint')
|
2018-03-11 14:15:17 +01:00
|
|
|
const uglify = require('gulp-uglify')
|
|
|
|
const rename = require('gulp-rename')
|
|
|
|
const minify = require('gulp-clean-css')
|
|
|
|
const connect = require('gulp-connect')
|
2020-03-03 21:01:35 +01:00
|
|
|
const autoprefixer = require('gulp-autoprefixer')
|
|
|
|
const pkg = require('./package.json')
|
2018-03-11 14:15:17 +01:00
|
|
|
|
2020-03-03 21:01:35 +01:00
|
|
|
const license = `/*!
|
|
|
|
* reveal.js <%= pkg.version %> (<%= new Date().toDateString() %>)
|
|
|
|
* <%= pkg.homepage %>
|
|
|
|
* MIT licensed
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Hakim El Hattab, https://hakim.se
|
|
|
|
*/\n`
|
2018-03-11 14:15:17 +01:00
|
|
|
|
2020-03-03 21:01:35 +01:00
|
|
|
gulp.task('js', () => gulp.src(['./js/reveal.js'])
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(header(license, {pkg: pkg}))
|
|
|
|
.pipe(rename('reveal.min.js'))
|
|
|
|
.pipe(gulp.dest('./js')))
|
|
|
|
|
|
|
|
gulp.task('css-themes', () => gulp.src(['./css/theme/source/*.{sass,scss}'])
|
|
|
|
.pipe(sass())
|
|
|
|
.pipe(gulp.dest('./css/theme')))
|
2018-03-11 14:15:17 +01:00
|
|
|
|
2018-05-14 20:01:59 +02:00
|
|
|
gulp.task('css-core', gulp.series(
|
2020-03-03 21:01:35 +01:00
|
|
|
|
|
|
|
() => gulp.src(['css/reveal.scss']).pipe(sass()).pipe(autoprefixer()).pipe(gulp.dest('./css')),
|
2018-05-14 20:01:59 +02:00
|
|
|
() => gulp.src(['css/reveal.css']).pipe(minify({
|
2018-03-11 14:15:17 +01:00
|
|
|
compatibility: 'ie9'
|
2020-03-03 21:01:35 +01:00
|
|
|
})).pipe(header(license, {pkg: pkg}))
|
|
|
|
.pipe(gulp.dest('./css'))
|
|
|
|
|
2018-05-14 20:01:59 +02:00
|
|
|
))
|
2018-03-11 14:15:17 +01:00
|
|
|
|
|
|
|
gulp.task('css', gulp.parallel('css-themes', 'css-core'))
|
|
|
|
|
2018-05-14 20:01:59 +02:00
|
|
|
gulp.task('test', gulp.series(
|
2020-03-03 21:01:35 +01:00
|
|
|
|
|
|
|
() => gulp.src(['./js/reveal.js']).pipe(eslint()).pipe(eslint.format()),
|
2018-05-14 20:01:59 +02:00
|
|
|
() => gulp.src(['./test/*.html']).pipe(qunit())
|
2020-03-03 21:01:35 +01:00
|
|
|
|
2018-05-14 20:01:59 +02:00
|
|
|
))
|
2018-03-11 14:15:17 +01:00
|
|
|
|
|
|
|
gulp.task('default', gulp.series(gulp.parallel('js', 'css'), 'test'))
|
|
|
|
|
2018-05-14 20:01:59 +02:00
|
|
|
gulp.task('package', gulp.series('default', () =>
|
2020-03-03 21:01:35 +01:00
|
|
|
|
2018-05-14 20:01:59 +02:00
|
|
|
gulp.src([
|
2018-03-11 14:15:17 +01:00
|
|
|
'./index.html',
|
|
|
|
'./css/**',
|
|
|
|
'./js/**',
|
|
|
|
'./lib/**',
|
|
|
|
'./images/**',
|
|
|
|
'./plugin/**',
|
|
|
|
'./**.md'
|
|
|
|
]).pipe(zip('reveal-js-presentation.zip')).pipe(gulp.dest('./'))
|
2020-03-03 21:01:35 +01:00
|
|
|
|
2018-05-14 20:01:59 +02:00
|
|
|
))
|
2018-03-11 14:15:17 +01:00
|
|
|
|
2018-05-14 20:01:59 +02:00
|
|
|
gulp.task('serve', () => {
|
2020-03-03 21:01:35 +01:00
|
|
|
|
2018-03-11 14:15:17 +01:00
|
|
|
connect.server({
|
|
|
|
root: '.',
|
|
|
|
livereload: true,
|
|
|
|
open: true,
|
|
|
|
useAvailablePort: true
|
|
|
|
})
|
2020-03-03 21:01:35 +01:00
|
|
|
|
2018-03-11 14:15:17 +01:00
|
|
|
gulp.watch(['js/reveal.js'], gulp.series('js'))
|
2020-03-03 21:01:35 +01:00
|
|
|
|
|
|
|
gulp.watch([
|
|
|
|
'css/theme/source/*.{sass,scss}',
|
2018-03-11 17:52:37 +01:00
|
|
|
'css/theme/template/*.{sass,scss}',
|
|
|
|
], gulp.series('css-themes'))
|
2020-03-03 21:01:35 +01:00
|
|
|
|
2018-03-11 17:52:37 +01:00
|
|
|
gulp.watch(['css/reveal.scss'], gulp.series('css-core'))
|
2020-03-03 21:01:35 +01:00
|
|
|
|
2018-03-11 14:15:17 +01:00
|
|
|
})
|