-
Notifications
You must be signed in to change notification settings - Fork 23
/
rollup.config.js
81 lines (78 loc) · 1.64 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
71
72
73
74
75
76
77
78
79
80
81
import { babel } from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import analyze from 'rollup-plugin-analyzer';
const plugins = [
typescript(),
babel({
include: 'src/**',
exclude: 'node_modules/**',
extensions: ['.js'],
babelHelpers: 'runtime',
presets: ['@babel/env', '@babel/preset-react'],
plugins: ['@babel/plugin-transform-runtime'],
}),
commonjs(),
analyze({
stdout: true,
summaryOnly: true,
}),
];
const external = [
/^@babel\/runtime\/?/,
/^@kitware\/vtk\.js/,
'react',
'react/jsx-runtime',
'regenerator-runtime',
'deep-equal',
];
export default [
{
input: 'src/index.ts',
output: [
{
dir: 'dist/esm',
format: 'esm',
preserveModules: true,
preserveModulesRoot: 'src',
},
{
file: 'dist/cjs/react-vtk.js',
format: 'cjs',
},
],
external,
plugins: [
nodeResolve({
browser: true,
preferBuiltins: false,
extensions: ['.js', '.ts', '.tsx'],
}),
...plugins,
],
},
{
input: 'src/index.ts',
output: [
{
file: 'dist/umd/react-vtk.js',
format: 'umd',
exports: 'named',
name: 'ReactVtkJS',
},
],
external,
plugins: [
nodeResolve({
// include: 'node_modules/**',
// don't rely on node builtins for web
preferBuiltins: false,
browser: true,
}),
...plugins,
terser(),
],
},
];