-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
50 lines (47 loc) · 1.17 KB
/
Copy pathrollup.config.mjs
File metadata and controls
50 lines (47 loc) · 1.17 KB
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
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import path from "node:path";
import url from "node:url";
const isWatching = !!process.env.ROLLUP_WATCH;
const sdPlugin = "com.ascend.japanesereviews.sdPlugin";
/**
* @type {import("rollup").RollupOptions}
*/
const config = {
input: "src/plugin.ts",
output: {
file: `${sdPlugin}/bin/plugin.js`,
format: "es",
sourcemap: isWatching,
},
external: (id) =>
id.startsWith("node:") ||
["@elgato/streamdeck", "@napi-rs/canvas", "ws"].includes(id) ||
id.startsWith("@elgato/"),
plugins: [
{
name: "emit-package-json",
generateBundle() {
this.emitFile({
fileName: "package.json",
source: JSON.stringify({ type: "module" }),
type: "asset",
});
},
},
typescript({
mapRoot: isWatching
? `./${path.relative(
`./${sdPlugin}/bin`,
path.dirname(url.fileURLToPath(import.meta.url))
)}`
: undefined,
}),
resolve({
browser: false,
exportConditions: ["node"],
preferBuiltins: true,
}),
],
};
export default config;