-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
116 lines (103 loc) · 2.21 KB
/
Copy pathrollup.config.js
File metadata and controls
116 lines (103 loc) · 2.21 KB
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
113
114
115
116
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve";
import replace from "@rollup/plugin-replace";
import typescript from "@rollup/plugin-typescript";
import { wasm } from "@rollup/plugin-wasm";
import url from "@rollup/plugin-url";
import { terser } from "rollup-plugin-terser";
import analyzer from "rollup-plugin-analyzer";
import pkg from "./package.json";
const production = process.env.NODE_ENV === "production";
const dir = "lib";
const input = "src/index.ts";
const plugins = [
replace({
preventAssignment: true,
"process.env.NODE_ENV": JSON.stringify(production),
}),
commonjs({
transformMixedEsModules: true,
}),
resolve({
jsnext: true,
main: true,
module: true,
browser: true,
preferBuiltins: true,
}),
url(),
wasm(),
json({
compact: true,
preferConst: true,
}),
typescript({
sourceMap: true,
inlineSources: !production,
declarationMap: true,
exclude: ["__tests__", "__tests__/*.test.ts"],
outDir: `${dir}`,
}),
analyzer(),
];
export default [
// UMD
{
input,
plugins: [
...plugins,
terser({
ecma: 2020,
mangle: { toplevel: true },
compress: {
module: true,
toplevel: true,
unsafe_arrows: true,
drop_console: true,
drop_debugger: true,
},
}),
],
output: {
name: "dutils",
file: pkg.browser,
format: "umd",
esModule: false,
interop: "default",
extend: true,
sourcemap: true,
},
},
// ESM and CJS
{
input,
plugins,
output: [
{
file: pkg.module,
format: "esm",
esModule: true,
interop: "esModule",
exports: "named",
sourcemap: true,
},
{
file: pkg.module.replace(".mjs", ".node.mjs"),
format: "esm",
esModule: true,
interop: "esModule",
exports: "named",
sourcemap: true,
},
{
file: pkg.main,
format: "cjs",
esModule: false,
interop: "defaultOnly",
exports: "default",
sourcemap: true,
},
],
},
];