-
Notifications
You must be signed in to change notification settings - Fork 50
/
rollup.config.mjs
112 lines (105 loc) · 1.9 KB
/
rollup.config.mjs
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
import typescript from "@rollup/plugin-typescript";
import json from "@rollup/plugin-json";
import { terser } from "rollup-plugin-terser";
// import gzipPlugin from 'rollup-plugin-gzip';
import license from "rollup-plugin-license";
const ALGORITHMS = [
"adler32",
"argon2",
"bcrypt",
"blake2b",
"blake2s",
"blake3",
"crc32",
"crc64",
"hmac",
"keccak",
"md4",
"md5",
"pbkdf2",
"ripemd160",
"scrypt",
"sha1",
"sha3",
"sha224",
"sha256",
"sha384",
"sha512",
"sm3",
"whirlpool",
"xxhash32",
"xxhash64",
"xxhash3",
"xxhash128",
];
const TERSER_CONFIG = {
output: {
comments: false,
},
};
const LICENSE_CONFIG = {
banner: {
commentStyle: "ignored",
content: `hash-wasm (https://www.npmjs.com/package/hash-wasm)
(c) Dani Biro
@license MIT`,
},
};
const MAIN_BUNDLE_CONFIG = {
input: "lib/index.ts",
output: [
{
file: "dist/index.umd.js",
name: "hashwasm",
format: "umd",
},
{
file: "dist/index.esm.js",
format: "es",
},
],
plugins: [json(), typescript(), license(LICENSE_CONFIG)],
};
const MINIFIED_MAIN_BUNDLE_CONFIG = {
input: "lib/index.ts",
output: [
{
file: "dist/index.umd.min.js",
name: "hashwasm",
format: "umd",
},
{
file: "dist/index.esm.min.js",
format: "es",
},
],
plugins: [
json(),
typescript(),
terser(TERSER_CONFIG),
license(LICENSE_CONFIG),
],
};
const INDIVIDUAL_BUNDLE_CONFIG = (algorithm) => ({
input: `lib/${algorithm}.ts`,
output: [
{
file: `dist/${algorithm}.umd.min.js`,
name: "hashwasm",
format: "umd",
extend: true,
},
],
plugins: [
json(),
typescript(),
terser(TERSER_CONFIG),
license(LICENSE_CONFIG),
// gzipPlugin(),
],
});
export default [
MAIN_BUNDLE_CONFIG,
MINIFIED_MAIN_BUNDLE_CONFIG,
...ALGORITHMS.map(INDIVIDUAL_BUNDLE_CONFIG),
];