forked from jquense/react-big-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
95 lines (88 loc) · 2.12 KB
/
rollup.config.mjs
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import path from 'path'
import * as url from 'url'
import nodeResolve from '@rollup/plugin-node-resolve'
import babel from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import replace from '@rollup/plugin-replace'
import clear from 'rollup-plugin-clear'
// removed sizeSnapshot, as it is not compatible with ESM
import { terser } from 'rollup-plugin-terser'
import pkg from './package.json' with { type: 'json' }
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
const input = './src/index.js'
const name = 'ReactBigCalendar'
const babelOptions = {
exclude: /node_modules/,
babelHelpers: 'runtime',
}
const globals = {
react: 'React',
'react-dom': 'ReactDOM',
}
const commonjsOptions = {
include: /node_modules/,
}
export default [
{
input,
output: {
file: './dist/react-big-calendar.js',
format: 'umd',
name,
globals,
interop: 'auto',
},
external: Object.keys(globals).push(/@babel\/runtime/),
plugins: [
// only use 'clear' on the first target
clear({
targets: ['./dist', './lib'],
watch: true,
}),
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
preventAssignment: true,
}),
nodeResolve(),
commonjs(commonjsOptions),
babel(babelOptions),
],
},
{
input,
output: {
file: './dist/react-big-calendar.min.js',
format: 'umd',
name,
globals,
interop: 'auto',
},
external: Object.keys(globals).push(/@babel\/runtime/),
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
preventAssignment: true,
}),
nodeResolve(),
commonjs(commonjsOptions),
babel(babelOptions),
terser(),
],
},
{
input,
output: {
file: pkg.module,
format: 'esm',
interop: 'auto',
},
// prevent bundling all dependencies
external: (id) => !id.startsWith('.') && !id.startsWith('/'),
plugins: [
babel({
...babelOptions,
configFile: path.join(__dirname, 'babel.config.esm.js'),
}),
],
},
]