-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
61 lines (57 loc) · 1.38 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
import json from "@rollup/plugin-json";
import nodeResolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import { dirname, join, parse } from "node:path";
import { RollupOptions } from "rollup";
import dts from "rollup-plugin-dts";
const banner = `/**!
* @author Elgato
* @module elgato/streamdeck
* @license MIT
* @copyright Copyright (c) Corsair Memory Inc.
*/`;
/**
* Gets the configuration based an input within the `src/` folder.
* @param input Partial path to the input.
* @returns Rollup configuration for the specified input.
*/
function getConfig(input: string): RollupOptions[] {
const outputDir = join("dist", dirname(input));
input = join("src", input);
const pathWithoutExtension = join(outputDir, `${parse(input).name}`);
return [
{
input,
output: [
{
file: `${pathWithoutExtension}.cjs`,
format: "cjs",
banner
},
{
file: `${pathWithoutExtension}.mjs`,
format: "es",
banner
}
],
plugins: [
typescript({
exclude: ["scripts/**/*.ts"]
}),
nodeResolve(),
json()
]
},
{
input,
output: [
{
file: `${pathWithoutExtension}.d.ts`,
banner
}
],
plugins: [json(), dts()]
}
];
}
export default [...getConfig("index.ts"), ...getConfig("streamdeck/plugins/index.ts"), ...getConfig("streamdeck/plugins/json.ts")] satisfies RollupOptions[];