-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrollup.config.ts
81 lines (74 loc) · 1.62 KB
/
rollup.config.ts
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
// Copyright (c) roydukkey. All rights reserved.
// Licensed under the MIT. See LICENSE file in the project root for full license information.
import json from '@rollup/plugin-json';
import license from 'rollup-plugin-license';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import typescript from 'rollup-plugin-ts';
import type { Plugin, RollupOptions } from 'rollup';
import { author, config, main, name, repository, version } from './package.json';
const commonPlugins = (subPackage = ''): Plugin[] => [
license({
banner: {
commentStyle: 'none',
content: `/*! ${
[
`${name}${subPackage.length ? `/${subPackage}` : ''} v${version}`,
`(c) ${author.name}`,
repository.url.replace('.git', `/blob/v${version}/LICENSE`)
].join(' | ')
} */`
}
})
];
const rollupConfig: RollupOptions[] = [
{
input: config.main,
external: [
'dot-prop'
],
output: {
file: main,
format: 'cjs'
},
plugins: [
nodeResolve(),
json(),
typescript({
transpiler: 'babel'
}),
...commonPlugins()
]
},
{
input: config.cli[0],
external: [
'./main'
],
output: {
file: config.cli[1],
format: 'cjs'
},
plugins: [
nodeResolve(),
json(),
typescript({
transpiler: 'babel',
tsconfig: (config) => ({
...config,
declaration: false
})
}),
replace({
preventAssignment: false,
delimiters: ['\'', '\''],
values: {
// eslint-disable-next-line @typescript-eslint/naming-convention
'./index': '"./main"'
}
}),
...commonPlugins('cli')
]
}
];
export default rollupConfig;