-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
101 lines (96 loc) · 2.65 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
import typescript from "@wessberg/rollup-plugin-ts";
import buble from "@rollup/plugin-buble";
import resolve from "@rollup/plugin-node-resolve";
import { minify as terserMinify } from "terser";
import pkg from "./package.json";
const name = "BIGBITMASK";
const sourceMap = true;
const extensions = [".ts"];
const bubleOptions = { transforms: { dangerousForOf: true } };
const terserOptions = { mangle: { module: true }, sourceMap: sourceMap };
const typescriptDeclarationsOptions = {
hook: { outputPath: (_, kind) => kind === "declaration" ? "dist/big-bit-mask.d.ts" : (kind === "declarationMap" && "dist/big-bit-mask.d.ts.map") },
tsconfig: resolvedConfig => ({ ...resolvedConfig, declaration: true, declarationMap: true }),
};
const input = "src/index.ts";
const config = [
{
input: input,
output: [
{
file: pkg.browser,
format: "umd",
name: name,
sourcemap: sourceMap,
},
{
file: pkg.browser.replace(/\.(m?js)$/, ".min.$1"),
format: "umd",
name: name,
plugins: [
terser(terserOptions),
],
sourcemap: sourceMap,
},
],
plugins: [
resolve({ extensions }),
typescript(),
buble(bubleOptions),
],
},
{
input: input,
output: [
{
file: pkg.module,
format: "esm",
sourcemap: sourceMap,
},
{
file: pkg.module.replace(/\.(m?js)$/, ".min.$1"),
format: "esm",
plugins: [
terser(terserOptions),
],
sourcemap: sourceMap,
},
],
plugins: [
resolve({ extensions }),
typescript(),
],
},
{
input: input,
output: {
file: pkg.main,
format: "cjs",
sourcemap: sourceMap,
},
plugins: [
resolve({ extensions }),
typescript(typescriptDeclarationsOptions),
],
},
{
input: input,
output: {
file: pkg.main.replace(/\.(m?js)$/, ".min.$1"),
format: "cjs",
sourcemap: sourceMap,
},
plugins: [
resolve({ extensions }),
typescript(),
terser(terserOptions),
],
},
];
export default config;
function terser(options = {}) {
return {
name: "terser",
renderChunk: (code) => terserMinify(code, options),
};
}