-
Notifications
You must be signed in to change notification settings - Fork 197
/
rollup.config.cjs.ts
48 lines (45 loc) · 1.25 KB
/
rollup.config.cjs.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
import terser from '@rollup/plugin-terser';
import { OutputOptions, Plugin, RollupOptions } from 'rollup';
const importMetaPlugin = {
name: 'import-meta',
resolveImportMeta() {
return '{}'; // prevent import.meta to be empty in non ES outputs
}
};
/**
* Creates the ESM flavor configurations for alphaTab
*/
export default function cjs(
isWatch: boolean,
commonOutput: Partial<OutputOptions>,
bundlePlugins: Plugin[]
): RollupOptions[] {
const withCjs = !isWatch || !!process.env.ALPHATAB_CJS;
if (!withCjs) {
return [];
}
return [
{
input: `src/alphaTab.main.ts`,
output: [
{
...commonOutput,
file: 'dist/alphaTab.js',
plugins: [importMetaPlugin],
sourcemap: true
},
{
...commonOutput,
file: 'dist/alphaTab.min.js',
plugins: [terser(), importMetaPlugin],
sourcemap: true
}
],
watch: {
include: ['src/**'],
exclude: 'node_modules/**'
},
plugins: [...bundlePlugins]
}
];
}