-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathrollup.config.ts
72 lines (67 loc) · 1.82 KB
/
rollup.config.ts
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
import { readFileSync } from 'node:fs'
import { extname } from 'node:path'
import { createFilter } from '@rollup/pluginutils'
import type { RollupOptions } from 'rollup'
import typescript from '@rollup/plugin-typescript'
import resolve from '@rollup/plugin-node-resolve'
import del from 'rollup-plugin-delete'
interface PNGOptions {
include?: string[]
exclude?: string[]
}
/**
* Transform imports of png's to base64
*/
const png = (options: PNGOptions = {}) => {
const filter = createFilter(options.include, options.exclude)
return {
name: 'png',
load(id: string) {
if (filter(id) && extname(id) === '.png') {
return `export default '${readFileSync(id, 'base64')}'`
}
}
}
}
const config: RollupOptions = {
input: 'src/index.ts',
output: [
{
name: 'VideoRecorder',
file: 'dist/wdio-video-reporter.mjs',
inlineDynamicImports: true,
format: 'es',
sourcemap: true,
exports: 'auto',
},
],
plugins: [
// @ts-expect-error see https://github.com/rollup/plugins/issues/1329
del({ targets: 'dist/*' }),
// @ts-expect-error see https://github.com/rollup/plugins/issues/1329
typescript({
exclude: ['rollup.config.ts']
}),
png(),
// @ts-expect-error see https://github.com/rollup/plugins/issues/1329
resolve({
modulesOnly: true,
preferBuiltins: true,
})
],
external: [
'mkdirp',
'fs-extra',
'@ffmpeg-installer/ffmpeg',
'@wdio/reporter',
'@wdio/logger',
'@wdio/globals',
'@wdio/allure-reporter',
'system-sleep',
'path',
'child_process',
'glob',
'util',
]
}
export default config