-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
49 lines (45 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
47
48
49
import path from 'path'
import packageJson from './package.json'
import typescript from 'rollup-plugin-typescript2'
import terser from '@rollup/plugin-terser'
import localTypescript from 'typescript'
const CONFIG_TYPESCRIPT = {
tsconfig: 'tsconfig.json',
typescript: localTypescript
}
const kebabCaseToPascalCase = (string = '') => {
return string.replace(/(^\w|-\w)/g, replaceString =>
replaceString.replace(/-/, '').toUpperCase()
)
}
const baseName = path.join('lib', 'index')
export default [
{
input: 'src/index.ts',
output: [
{
file: `${baseName}.js`,
format: 'cjs',
strict: true,
sourcemap: true,
exports: 'auto'
},
{
file: `${baseName}.esm.js`,
format: 'esm',
strict: true,
sourcemap: true
},
{
file: `${baseName}.umd.js`,
format: 'umd',
strict: true,
sourcemap: false,
name: kebabCaseToPascalCase(packageJson.name),
plugins: [terser()]
}
],
external: [],
plugins: [typescript(CONFIG_TYPESCRIPT)]
}
]