-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.decodeonly.mjs
102 lines (92 loc) · 2.18 KB
/
rollup.config.decodeonly.mjs
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
94
95
96
97
98
99
100
101
102
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import { defineConfig } from 'rollup'
import del from 'rollup-plugin-delete'
// @ts-expect-error untyped library
import istanbul from 'rollup-plugin-istanbul'
import license from 'rollup-plugin-license'
// @ts-expect-error tsc + rollup fight each other
import pkgJSON from './package.json' assert { type: 'json' }
const { author, name, version } = pkgJSON
/** @type {import('rollup').OutputOptions} */
const settings = {
globals: {
three: 'three'
},
sourcemap: !!process.env.PLAYWRIGHT_TESTING
}
const configBase = defineConfig({
external: ['three']
})
/** @type {import('rollup').InputPluginOption[]} */
const plugins = [
json(),
typescript({
tsconfig: 'src/tsconfig.json',
declaration: true,
sourceMap: !!process.env.PLAYWRIGHT_TESTING,
declarationDir: 'dist',
include: ['src/**/*.ts'],
exclude: ['src/libultrahdr.ts', 'src/libultrahdr/**/*.ts', 'src/encode.ts', 'src/encode/**/*.ts', 'src/worker*.ts']
}),
resolve(),
commonjs({
include: 'node_modules/**',
extensions: ['.js'],
ignoreGlobal: false,
sourceMap: !!process.env.PLAYWRIGHT_TESTING
}),
license({
banner: `
${name} v${version}
With ❤️, by ${author}
`
})
]
if (process.env.PLAYWRIGHT_TESTING) {
plugins.push(
istanbul({
include: ['src/**/*.ts']
})
)
}
/** @type {import('rollup').RollupOptions[]} */
let configs = [
defineConfig({
input: {
decode: './src/decode.ts'
},
output: {
dir: 'dist',
name,
format: 'es',
...settings
},
plugins: [
del({ targets: 'dist/*' }),
...plugins
],
...configBase
})
]
// configs to produce when not testing
// with playwright
if (!process.env.PLAYWRIGHT_TESTING) {
configs = configs.concat([
// decode UMD
defineConfig({
input: './src/decode.ts',
output: {
format: 'umd',
name,
file: 'dist/decode.umd.js',
...settings
},
plugins,
...configBase
})
])
}
export default configs