-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.ts
More file actions
65 lines (64 loc) · 1.43 KB
/
rollup.config.ts
File metadata and controls
65 lines (64 loc) · 1.43 KB
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
import { swc } from 'rollup-plugin-swc3';
import { dts } from 'rollup-plugin-dts';
import { defineConfig } from 'rollup';
import type { OutputChunk } from 'rollup';
import { bytes } from 'xbits';
export default defineConfig([{
input: 'src/index.ts',
output: [
{
file: 'dist/index.cjs',
format: 'cjs',
compact: true
},
{
file: 'dist/index.mjs',
format: 'esm',
compact: true
}
],
plugins: [
swc({
minify: true,
jsc: {
minify: {
mangle: {
topLevel: true
},
compress: {
ecma: 2020,
hoist_funs: true,
inline: 0,
keep_fargs: false,
passes: 3,
toplevel: true,
unsafe_arrows: true,
unsafe_symbols: true,
unsafe_methods: true,
unsafe_regexp: true
},
module: true
}
}
}),
{
name: 'rollup:simple-size',
generateBundle(options, bundle) {
if (options.file) {
const asset = options.file.split('/').pop()!;
const size = bytes((bundle[asset] as OutputChunk).code.length);
console.log(`Created bundle ${asset}: ${size}`);
} else {
console.error('No output file specified!');
}
}
}
]
}, {
input: 'src/index.ts',
output: {
file: 'dist/index.d.ts',
format: 'es'
},
plugins: [dts()]
}]);