-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
69 lines (64 loc) · 1.25 KB
/
rollup.config.mjs
File metadata and controls
69 lines (64 loc) · 1.25 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import bundleSize from 'rollup-plugin-bundle-size';
import clean from 'rollup-plugin-delete';
import license from 'rollup-plugin-license';
import pkg from './package.json' with { type: 'json' };
import cfg from './tsconfig.json' with { type: 'json' };
const createCommonPlugins = () => [
bundleSize(),
typescript({
declarationDir: './dist/types',
exclude: ['tests/**/*'],
}),
terser(),
license({
banner: {
commentStyle: 'ignored',
content: {
file: './config/banner.txt',
encoding: 'utf-8',
},
},
}),
];
const main = {
input: './src/index.ts',
output: [
{
format: 'umd',
file: pkg.main,
name: pkg.title,
sourcemap: true,
},
{
format: 'esm',
file: pkg.module,
sourcemap: true,
},
],
plugins: [
clean({
targets: `${cfg.compilerOptions.outDir}/*`,
}),
...createCommonPlugins(),
],
};
const util = {
input: './src/util.ts',
output: [
{
format: 'umd',
file: pkg.exports['./util'].require,
name: `${pkg.title}Utils`,
sourcemap: true,
},
{
format: 'esm',
file: pkg.exports['./util'].import,
sourcemap: true,
},
],
plugins: createCommonPlugins(),
};
export default [main, util];