-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
74 lines (70 loc) · 1.61 KB
/
rollup.config.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
/* eslint-disable @typescript-eslint/explicit-function-return-type */
import { nodeResolve } from "@rollup/plugin-node-resolve"
import terser from "@rollup/plugin-terser"
import typescript from "@rollup/plugin-typescript"
import { sync } from "rimraf"
function config({ format, minify, input, file }) {
const isJSON = file.endsWith("json")
const sourcemap = !isJSON
return {
input: `./src/${input}.ts`,
output: {
name: "TangoRPC",
file: file,
format,
inlineDynamicImports: true,
sourcemap,
},
plugins: [
nodeResolve(),
typescript({
tsconfig: "./tsconfig.tango-rpc.json",
outputToFilesystem: true,
compilerOptions: {
declaration: false,
sourceMap: true,
outDir: "dist",
},
}),
minify
? terser({
compress: true,
mangle: true,
format: {
comments: false,
},
})
: undefined,
isJSON
? {
name: "whatever",
renderChunk(code, chunk) {
return JSON.stringify(code)
},
}
: undefined,
].filter(Boolean),
}
}
sync("dist")
export default [
{
input: "tango-rpc-webview-script",
format: "umd",
minify: false,
file: "dist/umd/tango-rpc.js",
},
{
input: "tango-rpc-webview-script",
format: "umd",
minify: true,
file: "dist/umd/tango-rpc.mjs",
},
{
input: "tango-rpc-webview-script",
format: "umd",
minify: true,
ext: "json",
file: "src/tango-rpc-webview-script.json",
},
].map(config)