forked from liaobinbin/fig-to-json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
54 lines (48 loc) · 1.28 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
const path = require("path");
const json = require("@rollup/plugin-json");
const resolvePlugin = require("@rollup/plugin-node-resolve").default; // make sure to call .default
const commonjs = require("@rollup/plugin-commonjs"); // Add this line
const ts = require("rollup-plugin-typescript2");
const cleanup = require("rollup-plugin-cleanup");
const terser = require("rollup-plugin-terser");
const resolve = path.resolve;
const name = "FigToJSON";
const outputConfig = {
"esm-bundler": {
file: resolve(`dist/${name}.esm-bundler.js`),
format: "es",
},
cjs: {
file: resolve(`dist/${name}.cjs.js`),
format: "cjs",
},
global: {
file: resolve(`dist/${name}.global.js`),
format: "iife",
globals: {
'uzip': 'uzip' // Define the global variable name for 'uzip'
}
},
};
const createConfig = (format, output) => {
output.name = name;
output.sourcemap = true;
return {
input: resolve(`src/index.ts`),
output,
plugins: [
json(),
ts({
tsconfig: resolve(__dirname, "tsconfig.json"),
}),
resolvePlugin(),
commonjs(),
cleanup(),
terser.terser(),
],
};
};
const formats = Object.keys(outputConfig);
export default formats.map((format) => {
return createConfig(format, outputConfig[format]);
});