This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
74 lines (69 loc) · 1.67 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
import babel from '@rollup/plugin-babel'
import packageJson from './package.json'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
const { peerDependencies = {}, dependencies = {} } = packageJson
// If a dependency is "external" rollup will NOT change e.g.
// import { Button } from '@material-ui/core'
// to:
// import { Button } from '../../../node_modules/@material-ui/core'
// This WILL NOT happen if '@material-ui/core' is declared as external
const external = [
...Object.keys({
...peerDependencies,
...dependencies
}),
'@material-ui/core/styles',
'regenerator-runtime/runtime.js',
/@babel\/runtime/
]
console.log('External:', external)
export default {
input: 'src/index.js',
output: [
{
dir: 'dist.esm.modules',
format: 'es',
preserveModules: true
},
{
dir: 'dist.cjs.modules',
format: 'cjs',
preserveModules: true
}
],
plugins: [
// alias({
// applicationRoot: resolve(__dirname , '/src')
// }),
babel({
babelHelpers: 'runtime',
plugins: [
'@babel/plugin-transform-runtime',
[
'babel-plugin-styled-components',
{
displayName: false
}
],
['@babel/plugin-proposal-export-default-from'],
[
'module-resolver',
{
root: ['./src']
}
]
],
exclude: ['node_modules/**'],
presets: [
['@babel/preset-env', { modules: false }],
'@babel/preset-react'
]
}),
nodeResolve(),
commonjs(),
json()
],
external: external
}