forked from accordproject/web-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
79 lines (75 loc) · 1.96 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import postcss from 'rollup-plugin-postcss';
import filesize from 'rollup-plugin-filesize';
import includePaths from 'rollup-plugin-includepaths';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import autoprefixer from 'autoprefixer';
import postcssPresetEnv from 'postcss-preset-env';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
const outputs = [
{
file: process.env.REACT_APP_PKG_MAIN || pkg.main,
format: 'umd',
},
{
file: process.env.REACT_APP_PKG_MODULE || pkg.module,
format: 'es',
},
];
const postcssPlugins = [
postcssPresetEnv({
browsers: pkg.browserslist.production,
stage: 3,
}),
autoprefixer(),
];
const config = outputs.map(({ file, format }) => ({
input: 'src/index.js',
output: {
file,
format,
name: 'UIComponents',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'prop-types': 'PropTypes',
'@accordproject/ui-markdown-editor': 'MarkdownEditor',
'styled-components': 'styled',
'@accordproject/markdown-slate': 'markdownSlate',
'@accordproject/markdown-html': 'markdownHtml',
lodash: '_',
'semantic-ui-react': 'semanticUiReact'
},
exports: 'named',
},
plugins: [
peerDepsExternal(),
includePaths({
include: {},
paths: ['src'],
external: Object.keys(pkg.dependencies),
extensions: ['.js', '.json', '.html'],
}),
postcss({
extract: process.env.REACT_APP_PKG_STYLE || pkg.style,
inline: false,
plugins: postcssPlugins,
}),
babel({
babelHelpers: 'runtime',
exclude: 'node_modules/**',
configFile: './babel.config.rollup.js',
}),
resolve({
browser: true,
}),
commonjs(),
terser(),
filesize(),
],
external: ['@babel/runtime']
}));
export default config;