-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.mjs
75 lines (73 loc) · 2.13 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
75
import commonjs from "@rollup/plugin-commonjs";
import eslint from "@rollup/plugin-eslint";
import resolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import { glob } from "glob";
import path from "node:path";
import { fileURLToPath } from "node:url";
import analyze from "rollup-plugin-analyzer";
import del from "rollup-plugin-delete";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import versionInjector from "rollup-plugin-version-injector";
import { optimizeLodashImports } from "@optimize-lodash/rollup-plugin";
import shebang from "rollup-plugin-preserve-shebang";
/** @type {import("rollup").RollupOptions[]} */
const rollupOptions = [
{
input: "src/cli.ts",
output: [{ file: "bin/runtime-env", format: "commonjs" }],
plugins: [
del({ targets: "bin/*" }),
peerDepsExternal(),
optimizeLodashImports(),
resolve({ preferBuiltins: true }),
commonjs(),
versionInjector({ injectInTags: { fileRegexp: /^runtime-env$/ } }),
eslint({ throwOnError: true }),
typescript({
tsconfig: "./tsconfig.json",
}),
terser(),
shebang(),
analyze({
hideDeps: true,
limit: 0,
summaryOnly: true,
}),
],
},
{
input: Object.fromEntries(
glob
.sync(["src/*.ts"], { ignore: ["src/cli.ts"] })
.map((file) => [
path.relative(
"src",
file.slice(0, file.length - path.extname(file).length),
),
fileURLToPath(new URL(file, import.meta.url)),
]),
),
output: [{ dir: "dist", format: "commonjs", sourcemap: true }],
plugins: [
del({ targets: "dist/*" }),
peerDepsExternal(),
optimizeLodashImports(),
resolve({ preferBuiltins: true }),
commonjs(),
versionInjector(),
eslint({ throwOnError: true }),
typescript({
tsconfig: "./tsconfig.build.json",
}),
terser(),
analyze({
hideDeps: true,
limit: 0,
summaryOnly: true,
}),
],
},
];
export default rollupOptions;