forked from CoderLine/alphaTab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.cjs.ts
41 lines (39 loc) · 1.19 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
import terser from '@rollup/plugin-terser';
import { OutputOptions, Plugin, RollupOptions } from 'rollup';
const importMetaPlugin = {
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 | boolean)[] {
const withCjs = !isWatch || !!process.env.ALPHATAB_CJS;
return [
withCjs && {
input: `src/alphaTab.main.ts`,
output: [
{
file: 'dist/alphaTab.js',
plugins: [importMetaPlugin],
sourcemap: true
},
{
file: 'dist/alphaTab.min.js',
plugins: [terser(), importMetaPlugin],
sourcemap: true
}
].map(o => ({ ...commonOutput, ...o } as OutputOptions)),
watch: {
include: ['src/**'],
exclude: 'node_modules/**'
},
plugins: [...bundlePlugins]
}
];
}