-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
60 lines (56 loc) · 1.47 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
56
57
58
59
60
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import external from 'rollup-plugin-peer-deps-external';
import resolve from 'rollup-plugin-node-resolve';
import path from 'path';
const { LERNA_PACKAGE_NAME } = process.env;
const PACKAGE_ROOT_PATH = process.cwd();
const INPUT_FILE = path.join(PACKAGE_ROOT_PATH, 'src/index.js');
const OUTPUT_DIR = path.join(PACKAGE_ROOT_PATH, 'dist');
// eslint-disable-next-line import/no-dynamic-require
const PKG_JSON = require(path.join(PACKAGE_ROOT_PATH, 'package.json'));
const IS_BROWSER_BUNDLE = !!PKG_JSON.browser;
const LOCAL_GLOBALS = {
react: 'React',
'react-dom': 'ReactDOM',
'prop-types': 'PropTypes',
};
const formats = IS_BROWSER_BUNDLE ? ['umd'] : ['es', 'cjs'];
export default formats.map((format) => ({
input: INPUT_FILE,
external: [
'react',
'react-dom',
'prop-types',
'@tinacms/styles',
'@tinacms/icons',
'react-is',
],
output: {
file: path.join(OUTPUT_DIR, `index.${format}.js`),
format,
sourcemap: true,
name: LERNA_PACKAGE_NAME,
globals: LOCAL_GLOBALS,
amd: {
id: LERNA_PACKAGE_NAME,
},
},
plugins: [
external(),
babel({
runtimeHelpers: true,
exclude: [
'node_modules/**',
'../../node_modules/**',
],
presets: [
'@babel/preset-env',
'@babel/preset-react',
],
plugins: ['@babel/plugin-transform-runtime'],
}),
resolve(),
commonjs(),
],
}));