-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrollup.config.js
68 lines (63 loc) · 1.6 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
import babel from '@rollup/plugin-babel'
import svg from 'rollup-plugin-svg'
import styles from "rollup-plugin-styles"
const autoprefixer = require('autoprefixer')
import typescript from '@rollup/plugin-typescript'
// the entry point for the library
const input = 'src/index.ts'
let config = []
let MODE = [{ fomart: 'esm' }, { fomart: 'umd' }]
MODE.map((m) => {
let indexTs = {
input: input,
output: {
// then name of your package
name: "react-material-fileuploader",
file: `dist/index.${m.fomart}.js`,
format: m.fomart,
exports: "auto",
sourcemap: true,
globals: {
'react': 'React',
'prop-types': 'PropTypes',
'@mui/material': '@mui/material',
'@babel/runtime': '@babel/runtime',
'@mui/icons-material': '@mui/icons-material'
},
},
// this externelizes react to prevent rollup from compiling it
external: [
"react",
"@mui/icons-material",
"@mui/lab",
"@mui/material",
"prop-types",
/@babel\/runtime/
],
plugins: [
// these are babel comfigurations
babel({
exclude: 'node_modules/**',
plugins: [
'@babel/transform-runtime',
"@babel/plugin-proposal-optional-chaining"
],
babelHelpers: 'runtime'
}),
typescript({
tsconfig: './tsconfig.json',
}),
svg({ base64: true }),
// this adds support for styles
styles({
postcss: {
plugins: [
autoprefixer()
]
}
})
]
}
config.push(indexTs)
})
export default [ ...config ]