-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathrollup.config.js
More file actions
46 lines (43 loc) · 1.15 KB
/
rollup.config.js
File metadata and controls
46 lines (43 loc) · 1.15 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
import typescript from "@rollup/plugin-typescript";
import { extname, dirname, relative } from 'node:path';
import pkg from "./package.json" with { type: "json" };
import { globSync } from "node:fs";
import { fileURLToPath } from "node:url";
const external = (id) => [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.devDependencies),
].some((d) => id.startsWith(d));
const publishDir = dirname(pkg.module)
export default {
input: Object.fromEntries(
["src/index.ts", ...globSync('src/plugins/*/index.ts')].map((file) => [
relative('./src', file.slice(0, file.length - extname(file).length)),
fileURLToPath(new URL(file, import.meta.url)),
]),
),
output: [
{
dir: publishDir,
format: "cjs",
sourcemap: true,
entryFileNames: '[name].cjs',
},
{
dir: publishDir,
format: "es",
sourcemap: true,
entryFileNames: '[name].js',
},
],
external,
plugins: [
typescript({
tsconfig: "./tsconfig.json",
rootDir: "./src",
outDir: publishDir,
declaration: true,
declarationDir: publishDir,
exclude: ["**/*.{spec,stories}.*"],
}),
],
}