Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const glob = require('glob')
const yargs = require('yargs')
const through = require('through2');
const qunit = require('node-qunit-puppeteer')
const path = require('path');

const {rollup} = require('rollup')
const terser = require('@rollup/plugin-terser')
Expand All @@ -20,10 +21,26 @@ const minify = require('gulp-clean-css')
const connect = require('gulp-connect')
const autoprefixer = require('gulp-autoprefixer')

const root = yargs.argv.root || '.'

let rawFileArg = yargs.argv.file;

if (Array.isArray(rawFileArg)) {
rawFileArg = rawFileArg[rawFileArg.length - 1];
}

// 1. Set the server's root to the current working directory (which should be the reveal.js folder)
const root = process.cwd();

// 2. Calculate the absolute path to the file provided by the argument.
const absoluteFilePath = path.resolve(rawFileArg || 'index.html');

// 3. Calculate the path to the slide file *relative* to the server root (reveal.js folder).
const presentationFile = path.relative(root, absoluteFilePath);

const port = yargs.argv.port || 8000
const host = yargs.argv.host || 'localhost'


const cssLicense = `
reveal.js ${pkg.version}
${pkg.homepage}
Expand Down Expand Up @@ -293,7 +310,7 @@ gulp.task('package', gulp.series(async () => {

}))

gulp.task('reload', () => gulp.src(['index.html'])
gulp.task('reload', () => gulp.src([absoluteFilePath])
.pipe(connect.reload()));

gulp.task('serve', () => {
Expand All @@ -302,15 +319,15 @@ gulp.task('serve', () => {
root: root,
port: port,
host: host,
index: presentationFile,
livereload: true
})

const slidesRoot = root.endsWith('/') ? root : root + '/'
gulp.watch([
slidesRoot + '**/*.html',
slidesRoot + '**/*.md',
`!${slidesRoot}**/node_modules/**`, // ignore node_modules
], gulp.series('reload'))
const watchTargets = [
absoluteFilePath,
];

gulp.watch(watchTargets, gulp.series('reload'))

gulp.watch(['js/**'], gulp.series('js', 'reload', 'eslint'))

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.