-
Notifications
You must be signed in to change notification settings - Fork 226
/
rollup.config.js
41 lines (39 loc) · 1 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
import path from 'path'
import typescript from 'rollup-plugin-typescript2'
import findCacheDir from 'find-cache-dir'
const resolveCwd = path.resolve.bind(null, process.cwd())
const pkg = require(resolveCwd('package.json'))
const deps = Object.keys({...pkg.dependencies, ...pkg.peerDependencies})
const reExternal = new RegExp(`^(${deps.join('|')})($|/)`)
export default [
{
input: pkg.source,
output: [
{
file: pkg.main,
format: 'cjs',
},
{
file: pkg.module,
format: 'esm',
},
],
plugins: [
typescript({
cacheRoot: findCacheDir({
name: 'rollup-plugin-typescript2',
cwd: __dirname,
}),
tsconfigOverride: {
include: [resolveCwd('src/**/*')],
exclude: ['**/*.spec.*', '**/__tests__'],
compilerOptions: {
// reset to empty
paths: {},
},
},
}),
],
external: (id) => (deps.length ? reExternal.test(id) : false),
},
]