-
Notifications
You must be signed in to change notification settings - Fork 71
/
rollup.config.mjs
111 lines (106 loc) · 2.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
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
import path from "path";
import { fileURLToPath } from "url";
import nodePolyfills from "rollup-plugin-polyfill-node";
import typescript from "@rollup/plugin-typescript";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import terser from "@rollup/plugin-terser";
import multi from "@rollup/plugin-multi-entry";
import replace from "@rollup/plugin-replace";
const geckoBuild = {
input: "./src/http/index.fx.ts",
output: [
{
file: "dist/temp.js",
format: "module",
name: "KintoHttpClient",
generatedCode: {
objectShorthand: true,
},
},
],
plugins: [
resolve({
mainFields: ["module", "main", "browser"],
preferBuiltins: true,
}),
typescript({
include: ["*.ts+(|x)", "**/*.ts+(|x)", "*.js", "**/*.js"],
}),
],
};
const browserBuild = {
input: "./src/index.ts",
output: [
{
file: "dist/kinto.min.js",
format: "umd",
name: "Kinto",
sourcemap: true,
plugins: [terser()],
},
{
file: "dist/kinto.js",
format: "umd",
name: "Kinto",
sourcemap: true,
},
],
plugins: [
resolve({
mainFields: ["module", "main", "browser"],
preferBuiltins: true,
}),
typescript({
target: "es2017",
include: ["*.ts+(|x)", "**/*.ts+(|x)", "*.js", "**/*.js"],
}),
commonjs(),
],
};
const browserTestBuild = {
input: "./test/**/*_test.ts",
output: [
{
file: "dist/test-suite.js",
format: "iife",
sourcemap: true,
globals: {
intern: "intern",
},
},
],
plugins: [
multi(),
commonjs(),
nodePolyfills(),
resolve({
mainFields: ["browser", "module", "main"],
preferBuiltins: true,
}),
typescript({
tsconfig: "./test/tsconfig.json",
module: "esnext",
}),
replace({
preventAssignment: true,
__dirname: JSON.stringify(
path.join(path.dirname(fileURLToPath(import.meta.url)), "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];
export default bundles;