-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
84 lines (77 loc) · 1.73 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
import html from '@web/rollup-plugin-html';
import resolve from "@rollup/plugin-node-resolve"
import typescript from "@rollup/plugin-typescript"
import { terser } from "rollup-plugin-terser";
import { brotliCompressSync } from 'zlib'
import gzipPlugin from 'rollup-plugin-gzip'
export default [
{
external: ["@microsoft/fast-element"],
input: "src/index.ts",
output: [
{
name: "components",
file: "dist/components.umd.js",
format: "umd",
sourcemap: true,
exports: "named",
},
{
file: "dist/components.module.js",
format: "es",
sourcemap: true,
}
],
plugins: basePlugins()
},
// Compressed
{
input: "src/index.ts",
output: [
{
name: "components",
file: "dist/components.umd.min.js",
format: "umd",
sourcemap: true,
exports: "named"
},
{
file: "dist/components.module.min.js",
format: "es",
sourcemap: true,
}
],
plugins: compressionPlugins(),
},
// for previews
{
input: 'index.html',
output: { dir: 'demo' },
plugins: [resolve(), html()],
external: ["https://cdn.skypack.dev/hls.js", "Hls"],
}
]
function basePlugins(tsconfig = "tsconfig.json") {
return [
resolve(),
typescript({ tsconfig }),
]
}
function compressionPlugins(tsconfig = "tsconfig.json") {
return [
...basePlugins(tsconfig),
terser({
compress: {
passes: 10
}
}),
// GZIP compression as .gz files
gzipPlugin(),
// Brotil compression as .br files
gzipPlugin({
customCompression: content =>
brotliCompressSync(Buffer.from(content)),
fileName: '.br',
}),
]
}