-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
94 lines (83 loc) · 2.91 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
88
89
90
91
92
93
import {rollup} from 'rollup';
import {default as terser} from '@rollup/plugin-terser';
import babel from '@rollup/plugin-babel';
import {default as commonjs} from '@rollup/plugin-commonjs';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import gulp from 'gulp';
const babelConfig = {
babelHelpers: 'bundled',
ignore: ['node_modules'],
compact: false,
extensions: ['.js'],
presets: [
[
'@babel/preset-env',
{
corejs: 3,
useBuiltIns: 'usage',
modules: false,
targets: {
browsers: [
'last 2 Chrome versions',
'last 2 Safari versions',
'last 2 iOS versions',
'last 2 Firefox versions',
'last 2 Edge versions',
]
}
}
]
]
};
gulp.task('plugins', () =>
Promise.all([
{name: 'RevealRemote', file: 'remote'},
{name: 'RevealRemoteZoom', file: 'remotezoom'},
].flatMap(plugin =>
rollup({
input: `./plugin/${plugin.file}.js`,
plugins: [
nodeResolve(),
commonjs(),
babel({
...babelConfig,
ignore: [/node_modules\/.*/],
}),
terser()
],
external: ['../../socket.io/socket.io.esm.min.js'],
}).then(bundle => [
bundle.write({
file: `./dist/static/plugin/${plugin.file}.esm.js`,
name: plugin.name,
format: 'es',
}),
bundle.write({
file: `./dist/static/plugin/${plugin.file}.js`,
name: plugin.name,
format: 'iife',
globals: (file) => {
if (file.endsWith("/socket.io/socket.io.esm.min.js"))
return "io"
else
return file
}
})]
)
)
));
gulp.task('server', () =>
gulp.src('server/**/*')
.pipe(gulp.dest('dist')));
gulp.task('server-ui', () =>
gulp.src('server-ui/**/*')
.pipe(gulp.dest('dist/static/ui')));
gulp.task('demo-cjs', () =>
gulp.src(['presentations/commonjs/index.html', 'presentations/reveal.js/**/*'])
.pipe(gulp.dest('dist/presentations/commonjs')));
gulp.task('demo-esm', () =>
gulp.src(['presentations/esm/index.html', 'presentations/reveal.js/**/*'])
.pipe(gulp.dest('dist/presentations/esm')));
gulp.task('demo', gulp.parallel('demo-cjs', 'demo-esm'));
gulp.task('app', gulp.parallel('plugins', 'server', 'server-ui'));
gulp.task('default', gulp.parallel('app', 'demo'));