This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
rollup.config.js
115 lines (111 loc) · 3.14 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* eslint-env node */
import babel from "@rollup/plugin-babel";
import typescript from "rollup-plugin-typescript2";
import multiInput from "rollup-plugin-multi-input";
import fs from "fs";
import path from "path";
import postcss from "rollup-plugin-postcss";
import { DEFAULT_EXTENSIONS } from "@babel/core";
/**
* Recursively read files from `rootPath`. `rootPath` and `options` are passed
* through to `fs.readdir`. Has the same signature as `fs.readdirSync`.
*/
function recursiveReaddirSync(rootPath, options) {
const files = fs
.readdirSync(rootPath, options)
.map((filename) => {
const fullFilename = path.join(rootPath, filename);
return fs.statSync(fullFilename).isDirectory()
? recursiveReaddirSync(fullFilename, options)
: fullFilename;
})
.flat()
.filter((filename) =>
[".ts", ".tsx", ".js", ".jsx"].includes(path.extname(filename))
)
.map((filename) => path.relative(process.cwd(), filename));
return files;
}
function CJS() {
return {
input: recursiveReaddirSync(path.resolve("src"))
// Don't build tests or storybook stories
.filter((filename) => !/\.(?:spec|story|stories)/.test(filename))
// Exclude specific directories
.filter(
(filename) =>
![
path.join("src", "icons", "scripts"),
path.join("src", "illustrations", "scripts"),
path.join("src", "pictograms", "scripts"),
path.join("src", "shared"),
path.join("src", "AbstractTooltip"),
path.join("src", "ListConfig"),
].some((excludedPathname) => filename.includes(excludedPathname))
),
external: [
"@emotion/cache",
"@emotion/core",
"@popperjs/core",
"@popperjs/core/lib/utils/computeAutoPlacement",
"@popperjs/core/lib/utils/detectOverflow",
"@popperjs/core/lib/utils/getOppositePlacement",
"@popperjs/core/lib/utils/getOppositeVariationPlacement",
"@react-aria/focus",
"@react-aria/focus",
"@react-aria/switch",
"@react-aria/utils",
"@react-aria/utils",
"@react-aria/visually-hidden",
"@react-stately/toggle",
"@tippyjs/react",
"classnames",
"downshift",
"framer-motion",
"lodash/omit",
"lodash/uniqueId",
"prop-types",
"react-dom",
"react",
"tinycolor2",
"use-deep-compare-effect",
],
output: [
{
dir: ".",
format: "cjs",
sourcemap: true,
entryFileNames: "[name].js",
},
],
plugins: [
typescript({
check: false,
tsconfig: "tsconfig.build.json",
}),
multiInput({
relative: "src/",
}),
postcss({
extensions: [".css"],
}),
babel({
babelHelpers: "runtime",
extensions: [...DEFAULT_EXTENSIONS, ".ts", ".tsx"],
presets: [
[
"@babel/preset-react",
{
runtime: "classic",
importSource: "@emotion/core",
},
],
],
plugins: ["@babel/plugin-transform-runtime"],
}),
],
};
}
export default function () {
return [CJS()];
}