This repository has been archived by the owner on Sep 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
92 lines (87 loc) · 2.39 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
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import typescript from "@rollup/plugin-typescript";
import { dts } from "rollup-plugin-dts";
// Uncomment for UMD setup. Should not be needed unless we target non-Node.js environments.
// import { terser } from "rollup-plugin-terser";
// import babel from "@rollup/plugin-babel";
// import alias from "@rollup/plugin-alias";
// import { fileURLToPath } from "url";
import external from "rollup-plugin-peer-deps-external";
import css from "rollup-plugin-import-css";
import replace from "@rollup/plugin-replace";
const packageJson = require("./package.json");
const envKeys = () => {
const envRaw = require("dotenv").config().parsed || {};
return Object.keys(envRaw).reduce(
(envValues, envValue) => ({
...envValues,
[`process.env.${envValue}`]: JSON.stringify(envRaw[envValue]),
}),
{},
);
};
export default [
// Uncomment for UMD setup. Should not be needed unless we target non-Node.js environments.
// {
// // UMD
// input: "src/index.ts",
// plugins: [
// nodeResolve(),
// babel({
// babelHelpers: "bundled",
// }),
// terser(),
// alias({
// entries: {
// src: fileURLToPath(new URL("src", import.meta.url)),
// },
// }),
// ],
// output: {
// file: `dist/${packageJson.name}.min.js`,
// format: "umd",
// name: "markurz",
// esModule: false,
// exports: "named",
// sourcemap: true,
// },
// },
{
input: "src/index.ts",
output: [
{
file: packageJson.main,
format: "cjs",
sourcemap: true,
exports: "named",
},
{
file: packageJson.module,
format: "esm",
sourcemap: true,
exports: "named",
},
],
external: ["react", "react-dom"],
plugins: [
// Uncomment for UMD setup. Will resolve absolute imports to match the current file tree.
// alias({
// entries: {
// src: fileURLToPath(new URL("src", import.meta.url)),
// },
// }),
replace(envKeys()),
external(),
css(),
nodeResolve(),
commonjs(),
typescript({ tsconfig: "./tsconfig.json" }),
],
},
{
input: "dist/esm/types/index.d.ts",
output: [{ file: "dist/index.d.ts", format: "esm" }],
plugins: [dts()],
},
];