This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
rollup.config.js
128 lines (122 loc) · 2.98 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import path from "path";
import builtins from "rollup-plugin-node-builtins";
import nodePolyfills from "rollup-plugin-node-polyfills";
import typescript from "@rollup/plugin-typescript";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import inject from "@rollup/plugin-inject";
import { terser } from "rollup-plugin-terser";
import multi from "@rollup/plugin-multi-entry";
import replace from "@rollup/plugin-replace";
const geckoBuild = {
input: "./src/index.fx.ts",
output: [
{
file: "dist/temp.js",
format: "umd",
name: "KintoHttpClient",
},
],
plugins: [
resolve({
mainFields: ["module", "main", "browser"],
preferBuiltins: true,
}),
typescript({
include: ["*.ts+(|x)", "**/*.ts+(|x)", "*.js", "**/*.js"],
}),
commonjs({ ignoreGlobal: true }),
],
};
const browserBuild = {
input: "./src/index.browser.ts",
output: [
{
file: "dist/kinto-http.min.js",
format: "umd",
name: "KintoClient",
sourcemap: true,
},
],
plugins: [
resolve({
mainFields: ["module", "main", "browser"],
preferBuiltins: true,
}),
typescript({
include: ["*.ts+(|x)", "**/*.ts+(|x)", "*.js", "**/*.js"],
target: "es5",
}),
builtins(),
commonjs(),
terser(),
],
};
const nodeBuild = {
input: "./src/index.ts",
output: [
{
file: "dist/kinto-http.node.js",
format: "cjs",
sourcemap: true,
},
],
external: ["uuid", "node-fetch", "form-data", "atob"],
plugins: [
typescript({
include: ["*.ts+(|x)", "**/*.ts+(|x)", "*.js", "**/*.js"],
target: "es2018",
}),
inject({
fetch: "node-fetch",
Headers: ["node-fetch", "Headers"],
FormData: "form-data",
atob: "atob",
}),
commonjs(),
],
};
const browserTestBuild = {
input: "./test/*_test.ts",
output: [
{
file: "dist/test-suite.js",
format: "iife",
sourcemap: true,
globals: {
intern: "intern",
},
},
],
plugins: [
multi(),
commonjs({ extensions: [".js", ".ts"] }),
nodePolyfills(),
resolve({
mainFields: ["browser", "module", "main"],
preferBuiltins: true,
}),
typescript({
tsconfig: "./test/tsconfig.json",
module: "esnext",
}),
replace({
preventAssignment: true,
__dirname: JSON.stringify(path.join(__dirname, "test")),
"process.env.TEST_KINTO_SERVER": JSON.stringify(
process.env.TEST_KINTO_SERVER ? process.env.TEST_KINTO_SERVER : ""
),
"process.env.SERVER": JSON.stringify(
process.env.SERVER ? process.env.SERVER : ""
),
"process.env.KINTO_PROXY_SERVER": JSON.stringify(
process.env.SERVER ? process.env.SERVER : "http://localhost:8899"
),
"http://0.0.0.0": "http://localhost",
}),
],
};
const bundles = process.env.BROWSER_TESTING
? [browserTestBuild]
: [geckoBuild, browserBuild, nodeBuild];
export default bundles;