-
-
Notifications
You must be signed in to change notification settings - Fork 98
/
rollup.config.js
85 lines (81 loc) · 2 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
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import { nodeResolve } from '@rollup/plugin-node-resolve';
const addons = ["abort", "basicAuth", "formData", "formUrl", "perfs", "queryString", "progress"]
const middlewares = ["dedupe", "delay", "retry", "throttlingCache"]
const common = {
plugins: [
typescript({
importHelpers: true
}),
nodeResolve(),
terser({
ecma: 2018,
output: {
comments: false,
},
compress: {
booleans_as_integers: true,
passes: 2
}
})
],
external: ["url"]
}
const formats = ["umd", "cjs", "esm"]
const outputs = output => formats.map(format => ({
...output,
format,
file:
format === "cjs" ? output.file.replace(".js", ".cjs") :
format === "esm" ? output.file.replace(".js", ".mjs") :
output.file
}))
export default [
{
input: "./src/index.ts",
output: outputs({
file: "dist/bundle/wretch.min.js",
format: "umd",
name: "wretch",
exports: "default",
sourcemap: true
}),
...common
},
{
input: "./src/index.all.ts",
output: [
...outputs({
file: "dist/bundle/wretch.all.min.js",
format: "umd",
name: "wretch",
exports: "default",
sourcemap: true
})
],
...common
},
...addons.map(addon => ({
input: `./src/addons/${addon}.ts`,
output: outputs({
file: `dist/bundle/addons/${addon}.min.js`,
format: "umd",
name: `wretch${addon.charAt(0).toLocaleUpperCase() + addon.slice(1)}Addon`,
exports: "default",
sourcemap: true
}),
...common
})),
...middlewares.map(middleware => ({
input: `./src/middlewares/${middleware}.ts`,
output: outputs({
file: `dist/bundle/middlewares/${middleware}.min.js`,
format: "umd",
name: `wretch${middleware.charAt(0).toLocaleUpperCase() + middleware.slice(1)}Middleware`,
exports: "named",
sourcemap: true
}),
...common
}))
]