-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
51 lines (47 loc) · 1.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
import { nodeResolve } from "@rollup/plugin-node-resolve";
import sourcemaps from "rollup-plugin-sourcemaps";
import { terser } from "rollup-plugin-terser";
import typescript from "rollup-plugin-typescript2";
import getBanner from "../../scripts/banner";
import pkg from "./package.json";
console.info("Build @metablock/notebook");
const banner = getBanner(pkg);
const globals = { tslib: "tslib", "d3-require": "d3" };
const external = Object.keys({ tslib: "tslib" });
const config = (prod) => {
const plugins = [
sourcemaps(),
nodeResolve(),
typescript({
typescript: require("typescript"),
}),
];
if (prod) plugins.push(terser({ output: { preamble: banner } }));
return {
input: "src/index.ts",
output: [
{
file: pkg.module,
format: "es",
generatedCode: "es2015",
sourcemap: true,
banner,
globals,
},
{
file: pkg.main,
format: "cjs",
generatedCode: "es2015",
sourcemap: true,
banner,
globals,
},
],
external,
plugins,
watch: {
clearScreen: false,
},
};
};
export default config();