-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
39 lines (35 loc) · 1002 Bytes
/
rollup.config.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
38
39
import typescript from '@rollup/plugin-typescript';
import { nodeResolve as resolve } from '@rollup/plugin-node-resolve';
import common from '@rollup/plugin-commonjs';
import { terser } from 'rollup-plugin-terser';
import declaration from 'rollup-plugin-dts'
import { main, module, types } from './package.json';
const defaults = {
sourcemap: true,
};
function configure(...args) {
return args.reduce((carry, options) => {
const basic = { ...defaults, ...options };
const min = {
...basic,
file: basic.file.replace(/(\.[a-z]+)$/, '.min$1'),
plugins: [terser({ format: { comments: false } })],
};
return carry.concat(basic, min);
}, []);
}
export default [
{
input: 'source/main.ts',
output: configure(
{ file: main, format: 'cjs' },
{ file: module, format: 'es' },
),
plugins: [resolve({ exportConditions: ['node'] }), common(), typescript(), common()],
},
{
input: 'temp/main.d.ts',
output: { file: types, format: 'es' },
plugins: [declaration()],
}
];