-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathrollup.config.js
98 lines (94 loc) · 2.1 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
// const definition = require("./package.json");
// const dependencies = Object.keys(definition.dependencies);
// export default {
// input: "index.js",
// external: dependencies,
// output: {
// extend: true,
// file: `build/${definition.name}.js`,
// format: "umd",
// globals: dependencies.reduce((p, v) => (p[v] = "d3", p), {}),
// name: "d3"
// }
// };
import ascii from "rollup-plugin-ascii";
import node from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import terser from "@rollup/plugin-terser";
import meta from "./package.json" assert { type: "json" };
const copyright = `// ${meta.homepage} v${
meta.version
} Copyright ${new Date().getFullYear()} ${meta.author.name}`;
export default [
{
input: "src/forceInABox.js",
plugins: [
node({
jsxnext: true,
main: true,
browser: true,
}),
ascii(),
],
external: ["d3"],
output: {
extend: true,
banner: copyright,
file: "dist/forceInABox.js",
format: "umd",
indent: false,
name: "forceInABox",
globals: {
d3: "d3",
"d3-scale-chromatic": "d3ScaleChromatic",
},
},
},
{
input: "src/forceInABox.js",
plugins: [
node({
jsxnext: true,
}),
ascii(),
commonjs(),
],
external: ["d3"],
output: {
extend: true,
banner: copyright,
file: meta.module,
format: "esm",
indent: false,
name: "forceInABox",
globals: {
d3: "d3",
"d3-scale-chromatic": "d3ScaleChromatic",
},
},
},
{
input: "src/forceInABox",
plugins: [
node({
jsxnext: true,
main: true,
browser: true,
}),
ascii(),
terser({ output: { preamble: copyright } }),
],
external: ["d3", "d3-scale-chromatic"],
output: {
extend: true,
file: "dist/forceInABox.min.js",
format: "umd",
indent: false,
name: "forceInABox",
globals: {
d3: "d3",
"d3-scale-chromatic": "d3ScaleChromatic",
},
},
},
];