-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
43 lines (40 loc) · 1.03 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
const path = require("path");
const { defineConfig } = require("rollup");
const pkgJson = require("./package.json");
const { getBabelOutputPlugin } = require("@rollup/plugin-babel");
const resolve = require("@rollup/plugin-node-resolve");
const commonjs = require("@rollup/plugin-commonjs");
const ts2 = require("rollup-plugin-typescript2");
const getOutput = (
/** @type {import('rollup').RollupOptions}*/
config
) =>
defineConfig({
paths: "./build",
sourcemap: true,
...config,
});
/** @type {import('rollup').RollupOptions}*/
const options = {
input: "src/index.tsx",
plugins: [
getBabelOutputPlugin({
presets: ['@babel/preset-env'],
}),
commonjs(),
resolve(),
ts2({ config: "./tsconfig.json", extensions: [".js", ".ts", ".tsx"] }),
],
output: [
getOutput({
file: path.resolve(__dirname, pkgJson.main),
format: "cjs",
}),
getOutput({
file: path.resolve(__dirname, pkgJson.module),
format: "es",
}),
],
external: ["react"],
};
exports.default = options;