-
Notifications
You must be signed in to change notification settings - Fork 8
/
rollup.config.js
68 lines (63 loc) · 1.58 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 babel from "@rollup/plugin-babel";
import typescript from "@rollup/plugin-typescript";
import packageJson from "./package.json";
const banner = `/**
* ${packageJson.name} v${packageJson.version}
*
* Copyright (c) Matt Brophy ([email protected])
*
* This source code is licensed under the ISC license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license ISC
*/`;
let getOutputFile = (f) =>
[process.env.OUTPUT_DIR || "", f].join("/").replace(/^\//, "");
export default function rollup() {
const SOURCE_DIR = "src";
const output = {
sourcemap: true,
banner,
};
return [
// ESM module for bundlers
{
input: `${SOURCE_DIR}/index.tsx`,
output: [
{
file: getOutputFile(packageJson.main),
format: "cjs",
...output,
},
{
file: getOutputFile(packageJson.module),
format: "esm",
...output,
},
],
external: ["react", "@babel/runtime/helpers/extends"],
plugins: [
typescript(),
babel({
exclude: /node_modules/,
babelHelpers: "runtime",
presets: [
["@babel/preset-env", { loose: true, debug: true }],
"@babel/preset-react",
"@babel/preset-typescript",
],
plugins: [
[
"@babel/plugin-transform-runtime",
{
helpers: true,
regenerator: true,
},
],
],
extensions: [".ts", ".tsx"],
}),
],
},
];
}