-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrollup.config.js
48 lines (44 loc) · 951 Bytes
/
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
const cleanup = require('rollup-plugin-cleanup')
const { default: dts } = require('rollup-plugin-dts')
const typescript = require('@rollup/plugin-typescript')
const externals = require('rollup-plugin-node-externals')
const prod = process.env.NODE_ENV === 'production'
/**
* @type {Array<import('rollup').RollupOptions>}
*/
const config = [
{
input: './src/index.ts',
output: {
file: './dist/index.js',
format: 'cjs',
exports: 'named'
},
plugins: [
typescript(),
prod &&
cleanup({
comments: 'none',
extensions: ['ts', 'js']
}),
externals({
deps: true,
devDeps: true,
optDeps: true,
peerDeps: true
})
]
}
]
if (prod) {
config.push({
input: './src/index.ts',
plugins: [dts()],
output: {
file: './dist/index.d.ts',
format: 'es',
exports: 'named'
}
})
}
module.exports = config