-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.cjs
49 lines (46 loc) · 1.12 KB
/
tsup.config.cjs
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
import { defineConfig } from "tsup";
import umdWrapper from "esbuild-plugin-umd-wrapper";
import { umd, dependencies, version } from "./package.json";
const externalDependencies = Object.keys(dependencies);
const clientName = umd;
/** @type {import('tsup').Options} */
const baseConfig = {
entry: {
["toast-it"]: "src/index.ts",
},
outDir: "dist",
outExtension({ format, options }) {
const ext = { esm: "js", cjs: "cjs", umd: "umd.js" }[format];
const outputExtension = options.minify ? `min.${ext}` : `${ext}`;
return {
js: `.${outputExtension}`,
};
},
platform: "browser",
format: ["cjs", "esm"],
name: clientName,
globalName: clientName,
bundle: true,
esbuildPlugins: [],
banner: { js: `/*! toast-it v${version} | MIT */\n` },
define: {
__VERSION__: `'${version}'`,
},
noExternal: externalDependencies,
minify: false,
splitting: false,
sourcemap: true,
dts: true,
clean: true,
};
export default defineConfig([
{
...baseConfig,
esbuildPlugins: [],
},
{
...baseConfig,
format: ["umd"],
esbuildPlugins: [umdWrapper({ external: "inherit" })],
},
]);