-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
42 lines (38 loc) · 1.03 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
import commonjs from '@rollup/plugin-commonjs'
import { babel } from '@rollup/plugin-babel'
import typescript from '@rollup/plugin-typescript'
import del from 'rollup-plugin-delete'
const packageJson = require('./package.json')
const getConfig = (format) => {
const outputDir = `./dist/${format}`
return {
input: 'src/index.ts',
output: [
{
dir: outputDir,
format: format,
preserveModules: true,
preserveModulesRoot: 'src',
},
],
external: [...Object.keys(packageJson.peerDependencies || {})],
plugins: [
del({ targets: outputDir }),
commonjs(),
babel({
babelHelpers: 'bundled',
extensions: ['.ts'],
exclude: 'node_modules/**',
}),
typescript({
tsconfig: './tsconfig.json',
declarationDir: outputDir,
declaration: true,
noEmit: false,
emitDeclarationOnly: true,
exclude: ['**/*.test.ts', '**/*.test.tsx'],
}),
],
}
}
export default [getConfig('cjs'), getConfig('esm')]