-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.mjs
60 lines (57 loc) · 1.55 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
import babel from "@rollup/plugin-babel";
import clear from "rollup-plugin-clear";
import copy from "rollup-plugin-copy";
import filesize from "rollup-plugin-filesize";
import resolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
function createBundleConfig(input, output = {}) {
const targetDir = "lib";
const fileName = input.split("/").pop();
return {
input: `src/${input}.js`,
output: Object.assign(
{
file: `${targetDir}/${fileName}.js`,
format: "cjs",
sourcemap: true,
sourcemapFile: `${targetDir}/${fileName}.js.map`,
exports: "auto",
},
output,
),
plugins: [
clear({ targets: [targetDir] }),
resolve(),
babel({ babelHelpers: "bundled" }),
terser(),
filesize({
reporter: (_, __, { bundleSize, gzipSize }) =>
`Bundle size: ${bundleSize}, Gzipped size: ${gzipSize}`,
}),
copy({
targets: [
{
src: ["src/typings/*.d.ts"],
dest: targetDir,
},
],
}),
],
};
}
export default [
createBundleConfig("index", {
format: "umd",
name: "numberGenerator",
}),
createBundleConfig("index", {
format: "esm",
file: "lib/index.esm.js",
sourcemapFile: "lib/index.esm.js.map",
}),
createBundleConfig("fns/aleaRNGFactory"),
createBundleConfig("fns/murmurhash2_x86_32"),
createBundleConfig("fns/murmurhash3_x86_32"),
createBundleConfig("fns/murmurhash3_x86_128"),
createBundleConfig("fns/murmurhash3_x64_128"),
];