forked from Daninet/hash-wasm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
109 lines (101 loc) · 1.93 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
import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
import { terser } from '@el3um4s/rollup-plugin-terser';
// import gzipPlugin from 'rollup-plugin-gzip';
// [email protected] depends on rollup@^1 || rollup@^2, rollup 3 are not supported.
// import license from 'rollup-plugin-license';
const ALGORITHMS = [
'adler32',
'argon2',
'bcrypt',
'blake2b',
'blake2s',
'blake3',
'crc32',
'crc32c',
'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.js',
format: 'es',
},
],
plugins: [
json(),
typescript(),
// license(LICENSE_CONFIG),
],
};
const MINIFIED_MAIN_BUNDLE_CONFIG = {
input: 'lib/index.ts',
output: [
{
file: 'dist/index.min.js',
format: 'es',
},
],
plugins: [
json(),
typescript(),
terser(TERSER_CONFIG),
// license(LICENSE_CONFIG),
],
};
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const INDIVIDUAL_BUNDLE_CONFIG = (algorithm) => ({
input: `lib/${algorithm}.ts`,
output: [
{
file: `dist/${algorithm}.min.js`,
name: 'hashwasm',
format: 'es',
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),
];