-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
30 lines (25 loc) · 963 Bytes
/
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
import * as path from "path";
import * as fs from "fs/promises";
import { RollupOptions } from "rollup";
import terser from "@rollup/plugin-terser";
import tsc from "rollup-plugin-typescript2";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const build_path = path.resolve(__dirname, "public");
const entrypoint_path = path.resolve(__dirname, "src", "entrypoints");
async function main(): Promise<RollupOptions[]> {
const entrypoints = await fs.readdir(entrypoint_path);
return entrypoints.map((entrypoint) => ({
input: path.resolve(entrypoint_path, entrypoint),
output: {
file: path.resolve(build_path, path.basename(entrypoint, ".ts") + ".js"),
format: "iife",
name: entrypoint,
plugins: [terser()],
sourcemap: true,
},
plugins: [tsc({ "tsconfig": "./tsconfig.rollup.json", check: false })],
}));
}
export default main