-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.ts
44 lines (40 loc) · 1.03 KB
/
rollup.config.ts
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
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import resolve from '@rollup/plugin-node-resolve';
import swc from 'rollup-plugin-swc';
import packageJson from './package.json';
const plugins = [
resolve({
preferBuiltins: true,
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'],
}),
commonjs(),
replace({
values: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
__VERSION__: JSON.stringify(packageJson.version),
},
preventAssignment: true,
}),
swc({
minify: process.env.NODE_ENV === 'production',
sourceMaps: process.env.NODE_ENV !== 'production',
}),
];
const globals = {
'react': 'React',
'react-dom': 'ReactDOM',
'react/jsx-runtime': 'jsx',
'typescript': 'ts',
};
export default {
input: {
index: 'src/index.ts',
},
output: [
{ dir: './dist', format: 'esm', globals, exports: 'auto' },
{ dir: './dist/cjs', format: 'cjs', globals, exports: 'auto' },
],
external: Object.keys(globals),
plugins,
};