-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (69 loc) · 2.08 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const yargs = require('yargs')
const gulp = require('gulp')
const zip = require('gulp-zip')
const connect = require('gulp-connect')
const eslint = require('gulp-eslint');
const root = yargs.argv.root || '.'
const port = yargs.argv.port || 8000
const host = yargs.argv.host || 'localhost'
// Prevents warnings from opening too many test pages
process.setMaxListeners(20);
const babelConfig = {
babelHelpers: 'bundled',
ignore: ['node_modules'],
compact: false,
extensions: ['.js', '.html'],
plugins: [
'transform-html-import-to-string'
],
presets: [[
'@babel/preset-env',
{
corejs: 3,
useBuiltIns: 'usage',
modules: false
}
]]
};
// Our ES module bundle only targets newer browsers with
// module support. Browsers are targeted explicitly instead
// of using the "esmodule: true" target since that leads to
// polyfilling older browsers and a larger bundle.
const babelConfigESM = JSON.parse( JSON.stringify( babelConfig ) );
babelConfigESM.presets[0][1].targets = { browsers: [
'last 2 Chrome versions',
'last 2 Safari versions',
'last 2 iOS versions',
'last 2 Firefox versions',
'last 2 Edge versions',
] };
gulp.task('eslint', () => gulp.src(['./js/**', 'gulpfile.js'])
.pipe(eslint())
.pipe(eslint.format()))
gulp.task('package', gulp.series(() =>
gulp.src(
[
'./index.html',
'./dist/**',
'./lib/**',
'./images/**',
'./plugin/**',
'./**.md'
],
{ base: './' }
)
.pipe(zip('reveal-js-presentation.zip')).pipe(gulp.dest('./'))
))
gulp.task('reload', () => gulp.src(['*.html', '*.md'])
.pipe(connect.reload()));
gulp.task('serve', () => {
connect.server({
root: root,
port: port,
host: host,
livereload: true
})
gulp.watch(['*.html', '*.md', 'images/**'], gulp.series('reload'))
gulp.watch(['js/**'], gulp.series('reload', 'eslint'))
gulp.watch(['plugin/**/plugin.js', 'plugin/**/*.html'], gulp.series('reload'))
})