-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.mjs
43 lines (39 loc) · 904 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
41
42
43
// @ts-check
import dts from 'rollup-plugin-dts';
import esbuild from 'rollup-plugin-esbuild';
import pkg from './package.json' assert { type: 'json' };
/** @type {(config: import('rollup').RollupOptions) => import('rollup').RollupOptions} */
function bundle(config) {
return {
...config,
input: 'src/index.ts',
external: [
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.devDependencies || {}),
'fs',
'path',
],
};
}
/** @type {import('rollup').RollupOptions[]} */
const config = [
bundle({
plugins: [
esbuild({
target: ['node10'],
}),
],
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true },
],
}),
bundle({
plugins: [dts()],
output: {
file: pkg.typings,
format: 'es',
},
}),
];
export default config;