forked from visjs/vis-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.build.js
171 lines (168 loc) · 5.08 KB
/
rollup.build.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import assets from "postcss-assets";
import babel from "rollup-plugin-babel";
import commonjs from "rollup-plugin-commonjs";
import copy from "rollup-plugin-copy";
import { generateHeader } from "vis-dev-utils";
import nodeResolve from "rollup-plugin-node-resolve";
import packageJSON from "./package.json";
import postcss from "rollup-plugin-postcss";
import typescript from "rollup-plugin-typescript2";
import { readFileSync } from "fs";
import { terser } from "rollup-plugin-terser";
const babelrc = JSON.parse(readFileSync("./.babelrc"));
const banner = generateHeader();
export default [].concat.apply(
[],
[
{
external: {},
globals: {},
injectCSS: true,
input: "lib/index-standalone.ts",
variant: "standalone"
},
{
external: Object.keys(packageJSON.peerDependencies),
globals: {
keycharm: "keycharm",
moment: "moment",
"vis-data": "vis",
"vis-util": "vis"
},
injectCSS: false,
input: "lib/index-peer.ts",
variant: "peer"
}
].map(({ external, globals, injectCSS, input, variant }) => {
return [].concat.apply(
[],
[false, true].map(min => {
const esmFileWithoutExt = `${variant}/esm/vis-network${
min ? ".min" : ""
}`;
const umdFileWithoutExt = `${variant}/umd/vis-network${
min ? ".min" : ""
}`;
return [
{
input,
output: [
{
banner,
file: esmFileWithoutExt + ".js",
format: "esm",
sourcemap: true
},
{
banner,
exports: "named",
extend: true,
file: umdFileWithoutExt + ".js",
format: "umd",
globals,
name: "vis",
sourcemap: true
}
],
external,
plugins: [
copy({
targets: [
{
src: `./dev-lib/bundle-${variant}.d.ts`,
dest: ".",
rename: esmFileWithoutExt + ".d.ts"
},
{
src: `./dev-lib/bundle-${variant}.d.ts`,
dest: ".",
rename: umdFileWithoutExt + ".d.ts"
},
{
src: "./dev-lib/bundle-esm-index.d.ts",
dest: ".",
rename: `${variant}/index.d.ts`
},
{
src: "./dev-lib/bundle-esm-index.d.ts",
dest: ".",
rename: `${variant}/index.js`
},
{
src: "./dev-lib/bundle-vis-network-index.d.ts",
dest: ".",
rename: `${variant}/esm/index.d.ts`
},
{
src: "./dev-lib/bundle-vis-network-index.d.ts",
dest: ".",
rename: `${variant}/esm/index.js`
},
{
src: "./dev-lib/bundle-vis-network-index.d.ts",
dest: ".",
rename: `${variant}/umd/index.d.ts`
},
{
src: "./dev-lib/bundle-vis-network-index.d.ts",
dest: ".",
rename: `${variant}/umd/index.js`
},
{
src: "./dev-lib/bundle-css.d.ts",
dest: ".",
rename: "styles/index.d.ts"
},
{
src: "./dev-lib/bundle-css.d.ts",
dest: ".",
rename: "styles/index.js"
}
]
}),
nodeResolve({
extensions: [".ts", ".js", ".json"]
}),
typescript({
objectHashIgnoreUnknownHack: true,
tsconfig: "tsconfig.code.json"
}),
commonjs({
namedExports: {
timsort: ["sort"]
}
}),
babel({
...babelrc,
babelrc: false,
extensions: [".ts", ".js"],
runtimeHelpers: true
}),
postcss({
extract:
!injectCSS && `styles/vis-network${min ? ".min" : ""}.css`,
inject: injectCSS,
minimize: min,
sourceMap: true,
plugins: [
assets({
loadPaths: ["lib/assets/"]
})
]
}),
...(!min
? []
: [
terser({
output: {
comments: (_node, { value }) => /@license/.test(value)
}
})
])
]
}
];
})
);
})
);