-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.mjs
100 lines (93 loc) · 2.1 KB
/
rollup.config.mjs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import del from 'rollup-plugin-delete'
import copy from 'rollup-plugin-copy'
import path from 'path'
import * as dotenv from 'dotenv'
dotenv.config()
const bundle = (config) => ({
...config,
external: (id) => {
return !id.startsWith('.') && !path.isAbsolute(id)
}
})
const esbuildBaseConfig = {
minify: false,
tsconfig: './tsconfig.json',
sourceMap: false,
define: {
'process.env.CLIENT_ID': `"${process.env.CLIENT_ID}"`,
'process.env.CLIENT_SECRET': `"${process.env.CLIENT_SECRET}"`,
'process.env.DOC_API_KEY': `"${process.env.DOC_API_KEY}"`,
'process.env.TIME_ZONE': `"${process.env.TIME_ZONE}"`,
'process.env.DISABLE_OAUTH': `"${process.env.DISABLE_OAUTH}"`
}
}
const baseOutput = (config) => ({
format: 'commonjs',
sourcemap: true,
preserveModules: true,
...config
})
export default [
/// CLI BUILD
bundle({
input: './src/cli.ts',
plugins: [
del({ targets: 'dist/*' }),
peerDepsExternal({
packageJsonPath: './package.json'
}),
esbuild(esbuildBaseConfig)
],
output: baseOutput({
dir: `./dist/cli`
})
}),
{
input: './src/cli.ts',
plugins: [
dts({
tsconfig: './tsconfig.json'
})
],
output: baseOutput({
dir: `./dist/cli`
})
},
/// MODULE BUILD
bundle({
input: './src/module/index.ts',
plugins: [
peerDepsExternal({
packageJsonPath: './package.json'
}),
esbuild({ ...esbuildBaseConfig, define: undefined }),
copy({
targets: [
{
src: ['./package.json', './LICENSE.md', './README.md'],
dest: './dist/module'
}
]
})
],
output: baseOutput({
dir: `./dist/module`,
preserveModules: false
})
}),
{
input: './src/module/index.ts',
plugins: [
dts({
tsconfig: './tsconfig.json'
})
],
output: baseOutput({
dir: `./dist/module`,
preserveModules: false
})
}
]