-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
46 lines (44 loc) · 1.08 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
import { defineConfig } from 'rollup'
import terser from '@rollup/plugin-terser'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import {
EXTERNALS as external,
GLOBAL_NAME as globalName,
LIBRARY_NAME as libraryName
} from './rollup.constant'
export default defineConfig(
[
// CommonJS
{ output: { file: `lib/${libraryName}.js`, format: 'cjs', indent: false } },
// ES
{ output: { file: `es/${libraryName}.js`, format: 'es', indent: false } },
// UMD Development
{
output: {
file: `dist/${libraryName}.js`,
format: 'umd',
indent: false,
name: globalName
}
},
// UMD Production
{
output: {
file: `dist/${libraryName}.min.js`,
format: 'umd',
indent: false,
name: globalName
},
plugins: [
terser({
compress: { unsafe: true, pure_getters: true, unsafe_comps: true }
})
]
}
].map(({ plugins, ...rest }) => ({
...rest,
external,
input: 'src/index.js',
plugins: [...(plugins || []), nodeResolve()]
}))
)