forked from hyperjump-io/json-schema
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
30 lines (26 loc) · 895 Bytes
/
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
const resolve = require("@rollup/plugin-node-resolve");
const commonjs = require("@rollup/plugin-commonjs");
const { terser } = require("rollup-plugin-terser");
const flatMap = (fn, list) => list.reduce((acc, x) => acc.concat(fn(x)), []);
const combine = (lists, items) => flatMap((item) => lists.map((list) => [...list, item]), items);
const combinations = (...lists) => lists.reduce(combine, [[]]);
const formats = ["amd", "cjs", "esm", "iife", "umd", "system"];
const minify = [true, false];
const config = combinations(formats, minify);
module.exports = config.map(([format, minify]) => ({
input: "lib/index.js",
output: {
format: format,
file: `dist/json-schema-${format}${minify ? ".min" : ""}.js`,
name: "JsonSchema",
sourcemap: true,
exports: "named"
},
plugins: [
resolve({
browser: true
}),
commonjs(),
minify && terser()
]
}));