-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.base.js
37 lines (34 loc) · 902 Bytes
/
rollup.base.js
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
import { nodeResolve } from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import peerDepsExternal from "rollup-plugin-peer-deps-external";
// eslint-disable-next-line no-undef
const production = process.env.NODE_ENV === "production";
export function createRollupConfig(format, name = undefined) {
const outputDir = `dist/${format}`;
const typescriptOptions =
format == "es"
? {
declaration: true,
declarationDir: outputDir,
}
: {};
return {
input: "src/index.ts",
output: {
dir: outputDir,
format,
name,
sourcemap: true,
},
plugins: [
format == "es" ? peerDepsExternal() : null,
typescript({
rootDir: "src/",
sourceMap: !production,
inlineSources: !production,
...typescriptOptions,
}),
nodeResolve(),
],
};
}