-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.mjs
102 lines (96 loc) · 2.54 KB
/
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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import typescript from '@rollup/plugin-typescript';
import pkg from './package.json' assert { type: 'json' };
import terser from '@rollup/plugin-terser';
import bundleSize from 'rollup-plugin-bundle-size';
const banner = `
/*! ================================
${pkg.name} v${pkg.version}
(c) 2020-present ${pkg.author}
Released under ${pkg.license} License
================================== */
`;
/**
* @type {import('rollup/dist/rollup').InputOptions}
*/
const commonConfig = {
external: [
...Object.keys(pkg.dependencies ?? {}),
...Object.keys(pkg.optionalDependencies ?? {}),
...Object.keys(pkg.peerDependencies ?? {})
],
plugins: [
// it doesn't find the config by default and doesn't emit interface files
// todo - https://github.com/rollup/plugins/pull/791/files#diff-77ceb76f06466d761730b952567396e6b5c292cc4044441cdfdf048b4614881dR83 check those tests
typescript({ tsconfig: './tsconfig.json' }),
terser({
format: {
comments: (node, comment) => {
if (comment.type === "comment2") {
return /@upfront/.test(comment.value);
}
}
}
}),
bundleSize()
]
};
/**
* @type {import('rollup/dist/rollup').RollupOptions[]}
*/
const rollupConfig = [
{
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true,
banner
},
{
file: pkg.module,
format: 'es',
sourcemap: true,
banner
}
],
...commonConfig
},
{
input: 'src/array.ts',
output: [
{
file: 'array.min.js',
format: 'cjs',
sourcemap: true,
banner
},
{
file: 'array.es.min.js',
format: 'es',
sourcemap: true,
banner
}
],
...commonConfig
},
{
input: 'src/string.ts',
output: [
{
file: 'string.min.js',
format: 'cjs',
sourcemap: true,
banner
},
{
file: 'string.es.min.js',
format: 'es',
sourcemap: true,
banner
}
],
...commonConfig
}
];
export default rollupConfig;