-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
42 lines (39 loc) · 1.04 KB
/
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
40
41
42
import typescript from 'rollup-plugin-typescript2';
import replace from '@rollup/plugin-replace';
import pkg from './package.json';
const makeExternalPredicate = (externalArr) => {
if (externalArr.length === 0) {
return () => false;
}
const pattern = new RegExp(`^(${externalArr.join('|')})($|/)`);
return (id) => pattern.test(id);
};
export default [
// CommonJS (for Node) and ES module (for bundlers) build.
{
input: 'src/index.ts',
external: makeExternalPredicate([
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
]),
plugins: [
replace({
__name__: pkg.name,
__version__: pkg.version,
}),
typescript({
tsconfigOverride: {
include: ['./src/**/*'],
compilerOptions: {
rootDir: 'src',
outDir: 'dist',
},
},
}), // so Rollup can convert TypeScript to JavaScript
],
output: [
{file: pkg.main, format: 'cjs'},
{file: pkg.module, format: 'es'},
],
},
];