This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.mjs
82 lines (75 loc) · 2.03 KB
/
rollup.config.mjs
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
import commonjs from "@rollup/plugin-commonjs";
import nodeExternals from "rollup-plugin-node-externals";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import esbuild from "rollup-plugin-esbuild";
import json from "@rollup/plugin-json";
import path from "path";
/**
* The name of the project.
*
* @type {string}
*/
const name = "mantine-extras";
/**
* Get a base configuration
*
* @param {import("rollup").ModuleFormat} type Type to get base for
* @param {boolean} [toMinify=false] Whether to create minified output
* @return {import("rollup").RollupOptions}
*/
function getBase(type, toMinify = false) {
const umd = type === "umd"
const shouldMinify = toMinify || umd;
return {
"input": "./src/index.ts",
"output": {
name,
"file": umd ? "./lib/index.umd.js" : undefined,
"dir": umd ? undefined : type,
"format": type,
"externalLiveBindings": false,
"preserveModules": !umd
},
"plugins": [
commonjs(),
nodeExternals(),
nodeResolve({
"extensions": [
".ts",
".tsx",
".js",
".jsx"
]
}),
esbuild({
"minify": shouldMinify,
"sourceMap": false,
"tsconfig": path.resolve(process.cwd(), "tsconfig.json")
}),
json({
"compact": shouldMinify
})
],
"external": [
"fs/promises"
]
};
}
/**
* Get the config for a build type.
*
* @param {import("rollup").ModuleFormat} types Types to build
* @return {import("rollup").RollupOptions[]}
*/
function getConfig(...types) {
/**
* @type {import("rollup").RollupOptions[]}
*/
const configs = [];
// Generate config for each type
for (const type of types) {
configs.push(getBase(type));
}
return configs;
}
export default getConfig("cjs", "esm");