-
Notifications
You must be signed in to change notification settings - Fork 11
/
rollup.config.js
50 lines (42 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
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
const input = 'src/react-scroll-up-button.js';
const babelOptionsCJS = {
exclude: /node_modules/,
};
const babelOptionsESM = {
exclude: /node_modules/,
runtimeHelpers: true,
plugins: [['@babel/transform-runtime', { useESModules: true }]],
};
const external = id => !id.startsWith('.') && !id.startsWith('/');
export default [
{
input,
output: { file: `dist/cjs/${pkg.name}.js`, format: 'cjs' },
external,
plugins: [
babel(babelOptionsCJS),
replace({ 'process.env.NODE_ENV': JSON.stringify('development') }),
],
},
{
input,
output: { file: `dist/cjs/${pkg.name}.min.js`, format: 'cjs' },
external,
plugins: [
babel(babelOptionsCJS),
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
terser(),
],
},
{
input,
output: { file: `dist/esm/${pkg.name}.js`, format: 'esm' },
external,
plugins: [babel(babelOptionsESM), sizeSnapshot()],
},
];