-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
70 lines (66 loc) · 1.93 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
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
import typescript from 'rollup-plugin-typescript2';
import commonjs from '@rollup/plugin-commonjs';
import pkg from './package.json';
import resolve from '@rollup/plugin-node-resolve';
import json from '@rollup/plugin-json';
import copy from 'rollup-plugin-copy';
import ts from 'typescript';
const entryPoint = './src/index.ts';
const dependencies = Object.keys(pkg.dependencies || {});
const peerDependencies = Object.keys(pkg.peerDependencies || {});
const esOutputDir = `./dist/${pkg.module}`;
const cjsOutputDir = `./dist/${pkg.main}`;
export default {
input: entryPoint,
external: [...dependencies, ...peerDependencies],
output: [
{
file: esOutputDir,
format: 'es',
sourcemap: true,
},
{
file: cjsOutputDir,
format: 'cjs',
sourcemap: true,
},
],
plugins: [
json(),
resolve({
browser: true,
}),
commonjs(),
typescript({
typescript: ts,
tsconfig: 'tsconfig.json',
tsconfigDefaults: {
exclude: [
'**/*.spec.ts',
'**/*.test.ts',
'node_modules',
'dist',
],
compilerOptions: {
sourceMap: true,
declaration: true,
},
},
}),
copy({
targets: [
{ src: 'README.md', dest: 'dist' },
{
src: 'package.json',
dest: 'dist',
transform: (content) => {
const { scripts, devDependencies, engines, ...keep } = JSON.parse(
content.toString()
);
return JSON.stringify(keep, null, 2);
},
},
],
}),
],
};