mirror of
https://github.com/d3/d3.git
synced 2025-12-08 19:46:24 +00:00
60 lines
1.2 KiB
JavaScript
60 lines
1.2 KiB
JavaScript
import {readFileSync} from "fs";
|
|
import json from "@rollup/plugin-json";
|
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
import ascii from "rollup-plugin-ascii";
|
|
import {terser} from "rollup-plugin-terser";
|
|
import * as meta from "./package.json";
|
|
|
|
// Extract copyrights from the LICENSE.
|
|
const copyright = readFileSync("./LICENSE", "utf-8")
|
|
.split(/\n/g)
|
|
.filter(line => /^Copyright\s+/.test(line))
|
|
.map(line => line.replace(/^Copyright\s+/, ""))
|
|
.join(", ");
|
|
|
|
const config = {
|
|
input: "bundle.js",
|
|
output: {
|
|
file: `dist/${meta.name}.js`,
|
|
name: "d3",
|
|
format: "umd",
|
|
indent: false,
|
|
extend: true,
|
|
banner: `// ${meta.homepage} v${meta.version} Copyright ${copyright}`
|
|
},
|
|
plugins: [
|
|
nodeResolve(),
|
|
json(),
|
|
ascii()
|
|
],
|
|
onwarn(message, warn) {
|
|
if (message.code === "CIRCULAR_DEPENDENCY") return;
|
|
warn(message);
|
|
}
|
|
};
|
|
|
|
export default [
|
|
config,
|
|
{
|
|
...config,
|
|
output: {
|
|
...config.output,
|
|
file: `dist/${meta.name}.min.js`
|
|
},
|
|
plugins: [
|
|
...config.plugins,
|
|
terser({
|
|
output: {
|
|
preamble: config.output.banner
|
|
},
|
|
mangle: {
|
|
reserved: [
|
|
"InternMap",
|
|
"InternSet"
|
|
]
|
|
}
|
|
})
|
|
]
|
|
}
|
|
];
|