-
Notifications
You must be signed in to change notification settings - Fork 24
/
rollup.config.js
68 lines (65 loc) · 1.7 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
import json from "@rollup/plugin-json";
import babel from "@rollup/plugin-babel";
import pkg from "./package.json";
const reporters = ["boxen"];
let filesize = () => {};
try {
// We can't point to ESM source here due to this pre-Node13 config (even if
// switched to the expected .mjs extension), being transpiled and then executed,
// causing `import.meta.url` (which we use to discover the relative reporter path)
// to reflect the rollup config file path instead of source (or dist).
// See discussion at https://github.com/rollup/rollup/pull/3445
filesize = require("./dist/index.js");
} catch (err) {
// We can't use the first time, with the file not yet built
}
export default [
{
external: ["path", "fs", "util", ...Object.keys(pkg.dependencies)],
plugins: [
json(),
babel({
babelrc: false,
babelHelpers: "runtime",
plugins: [
"@babel/plugin-transform-runtime",
"@babel/plugin-syntax-import-meta",
],
presets: [["@babel/preset-env", { targets: { node: 10 } }]],
}),
filesize({
showBeforeSizes: "release",
}),
],
input: "src/index.js",
output: {
exports: "default",
sourcemap: true,
file: `dist/index.js`,
format: "cjs",
},
},
...reporters.map((reporter) => {
return {
external: ["@babel/runtime"],
plugins: [
babel({
babelrc: false,
babelHelpers: "runtime",
plugins: ["@babel/plugin-transform-runtime"],
presets: [["@babel/preset-env", { targets: { node: 10 } }]],
}),
filesize({
showBeforeSizes: "release",
}),
],
input: `src/reporters/${reporter}`,
output: {
exports: "named",
sourcemap: true,
file: `dist/reporters/${reporter}.js`,
format: "cjs",
},
};
}),
];