-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.mjs
40 lines (37 loc) · 947 Bytes
/
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
import peerDepsExternal from "rollup-plugin-peer-deps-external";
import ts from 'rollup-plugin-ts';
import fs from "fs";
import { dirname } from 'path';
const pkg = JSON.parse(fs.readFileSync("./package.json"));
const baseConfig = {
input: 'src/index.ts',
}
export default [{
...baseConfig,
output: [{
preserveModules: true,
dir: dirname(pkg.main),
format: 'cjs',
sourcemap: 'inline'
}, {
preserveModules: true,
dir: dirname(pkg.module),
format: 'esm',
sourcemap: 'inline'
}],
plugins: [
peerDepsExternal(), // React
ts({ tsconfig: "./tsconfig.json" }),
]
}, {
...baseConfig,
output: {
dir: dirname(pkg.types),
format: 'esm'
},
plugins: [ts({ tsconfig: {
...JSON.parse(fs.readFileSync("./tsconfig.json")).compilerOptions,
emitDeclarationOnly: true,
declaration: true
}, })]
}]