-
Notifications
You must be signed in to change notification settings - Fork 28
/
rollup.config.js
31 lines (27 loc) · 1 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
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import esbuild from 'rollup-plugin-esbuild';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
const isProduction = process.env.NODE_ENV === 'production';
const deps = Object.keys(pkg.dependencies || {});
const peerDeps = Object.keys(pkg.peerDependencies || {});
const config = {
input: 'src/index.ts',
external: [...deps, ...peerDeps],
output: [
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ dir: 'dist', format: 'esm', preserveModules: true, preserveModulesRoot: 'src', sourcemap: true },
],
plugins: [
replace({ preventAssignment: true, 'process.env.REACT_SDK_VERSION': JSON.stringify(pkg.version) }),
commonjs(),
esbuild({ format: 'esm' }),
resolve(),
isProduction && terser(),
typescript({ sourceMap: true }),
],
};
export default config;