forked from BenLorantfy/nestjs-zod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
executable file
·129 lines (125 loc) · 2.42 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { defineConfig } from 'rollup'
import dts from 'rollup-plugin-dts'
import esbuild from 'rollup-plugin-esbuild'
import { terser } from 'rollup-plugin-terser'
import bundleSize from 'rollup-plugin-bundle-size'
import copy from 'rollup-plugin-copy'
const src = (file) => `src/${file}`
const dist = (file) => `dist/${file}`
const root = (file) => `${file}`
const bundle = (input, config) =>
defineConfig({
...config,
input,
external: (id) => !/^[./]/.test(id),
plugins: [
...(config.plugins || []),
bundleSize()
]
})
const config = defineConfig([
bundle(src('index.ts'), {
plugins: [esbuild()],
output: [
{
file: dist('index.js'),
format: 'cjs',
},
],
}),
bundle(src('index.ts'), {
plugins: [dts()],
output: [
{
file: dist('index.d.ts'),
format: 'es',
},
],
}),
bundle(src('z/exports/everything.ts'), {
plugins: [esbuild()],
output: [
{
file: dist('z.js'),
format: 'cjs',
},
{
file: dist('z.mjs'),
format: 'es',
},
],
}),
bundle(src('z/exports/only-override.ts'), {
plugins: [
dts(),
copy({
targets: [
{
src: './z.d.ts',
dest: 'dist',
transform: (contents) => contents.toString().replaceAll('./dist', '.'),
}
],
}),
],
output: [
{
file: dist('z-only-override.d.ts'),
format: 'es',
},
],
}),
bundle(src('frontend/index.ts'), {
plugins: [esbuild(), terser()],
output: [
{
file: dist('frontend.mjs'),
format: 'es',
},
{
file: dist('frontend.js'),
format: 'cjs',
},
],
}),
bundle(src('frontend/index.ts'), {
plugins: [dts()],
output: [
{
file: root('frontend.d.ts'),
format: 'es',
},
{
file: dist('frontend.d.ts'),
format: 'es',
},
],
}),
bundle(src('dto.ts'), {
plugins: [esbuild()],
output: [
{
file: dist('dto.mjs'),
format: 'es',
},
{
file: dist('dto.js'),
format: 'cjs',
},
],
}),
bundle(src('dto.ts'), {
plugins: [dts()],
output: [
{
file: root('dto.d.ts'),
format: 'es',
},
{
file: dist('dto.d.ts'),
format: 'es',
},
],
}),
])
export default config