-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
rollup.config.ts
78 lines (75 loc) · 2.08 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
import { glob } from 'glob';
import minifyHtml from 'rollup-plugin-minify-html-literals';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
import filesize from 'rollup-plugin-filesize';
import { defineConfig } from 'rollup';
const prod = process.env.NODE_ENV === 'production';
const input = glob.sync('src/**/*.ts');
export default defineConfig({
input,
output: {
dir: '.',
format: 'es',
sourcemap: prod ? true : 'inline',
preserveModules: true,
},
plugins: [
...(prod
? [
minifyHtml({
options: {
shouldMinify: (template) =>
template.parts[0].text.startsWith('<!-- html -->'),
shouldMinifyCSS: (template) =>
template.parts[0].text.startsWith('/* css */'),
minifyOptions: {
minifyCSS: {
level: {
2: {
all: true,
},
},
},
minifyJS: true,
collapseWhitespace: true,
collapseBooleanAttributes: true,
collapseInlineTagWhitespace: true,
removeOptionalTags: true,
removeTagWhitespace: true,
sortAttributes: true,
sortClassName: true,
removeRedundantAttributes: true,
},
},
}),
]
: []),
typescript({
tsconfig: 'tsconfig.build.json',
useTsconfigDeclarationDir: true,
}),
...(prod
? [
terser({
ecma: 2020,
mangle: {
properties: {
regex: /^_/,
},
},
}),
]
: []),
...(prod
? [
filesize({
showMinifiedSize: false,
// TODO: set this to true as soon as Bun gets support for Brotli in its zlib implementation
// See: https://github.com/oven-sh/bun/issues/267
showBrotliSize: false,
}),
]
: []),
],
});