-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
85 lines (83 loc) · 2.05 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
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
import alias from '@rollup/plugin-alias';
import copy from 'rollup-plugin-copy';
import dts from 'rollup-plugin-dts';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import resolve from '@rollup/plugin-node-resolve';
export default [
...[
['src/index.ts', { output: { name: 'MVVM', dir: 'lib' } }],
['src/renderer/dom/index.ts', { output: { name: 'MVVM.dom', dir: 'lib/dom' } }],
].flatMap(([input, { output }]) => [
{
input,
external: ['..'],
output: [
{
...output,
entryFileNames: '[name].js',
format: 'umd',
exports: 'named',
sourcemap: true,
sourcemapExcludeSources: true,
globals: {
'..': 'MVVM',
},
},
{
...output,
entryFileNames: '[name].mjs',
format: 'esm',
sourcemap: true,
sourcemapExcludeSources: true,
globals: {
'..': 'MVVM',
},
},
],
plugins: [
alias({ entries: { 'mvvm.js': '..' } }),
typescript({
cacheRoot: './node_modules/.cache/rpt2',
useTsconfigDeclarationDir: true,
}),
terser({
ecma: 6,
mangle: false,
compress: false,
output: {
beautify: true,
comments: false,
},
}),
],
},
]),
...[
['src/index.ts', { output: { dir: 'lib' } }],
[
'src/renderer/dom/index.ts',
{
output: { dir: 'lib/dom' },
plugins: [copy({ targets: [{ src: 'src/renderer/dom/jsx.d.ts', dest: 'lib/dom' }] })],
},
],
].map(([input, { output, plugins }]) => ({
input,
external: ['..', 'ts-toolbelt'],
output: {
...output,
entryFileNames: '[name].d.ts',
format: 'es',
},
plugins: [
...(plugins || []),
resolve({
extensions: ['.d.ts'],
mainFields: ['types'],
}),
alias({ entries: { 'mvvm.js': '..' } }),
dts(),
],
})),
];