forked from draft-js-plugins/draft-js-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
55 lines (53 loc) · 1.16 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
import path from 'path';
import nodeResolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import { existsSync } from 'fs';
const input = existsSync('./src/index.ts')
? './src/index.ts'
: './src/index.tsx';
const external = (id) => !id.startsWith('.') && !path.isAbsolute(id);
const extensions = ['.ts', '.js', '.tsx', '.jsx'];
const babelOptions = {
rootMode: 'upward',
extensions,
babelHelpers: 'bundled',
};
export default [
{
input,
output: {
format: 'cjs',
file: './lib/index.cjs.js',
exports: 'named',
},
external,
plugins: [nodeResolve({ extensions }), babel(babelOptions)],
},
{
input,
output: {
format: 'esm',
file: './lib/index.esm.js',
},
external,
plugins: [
nodeResolve({ extensions }),
babel({
...babelOptions,
plugins: [
[
'babel-plugin-transform-rename-import',
{
replacements: [
{
original: 'lodash',
replacement: 'lodash-es',
},
],
},
],
],
}),
],
},
];