forked from aptos-labs/aptos-ts-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsup.config.ts
58 lines (52 loc) · 1.51 KB
/
tsup.config.ts
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
import { defineConfig } from "tsup";
import type { Options, Format } from "tsup";
// Ensure that these option fields are not undefined
type MandatoryOptions = Options & {
outDir: string;
platform: string;
format: Format | Format[];
};
// Default config, used as a base template
const DEFAULT_CONFIG: Options = {
bundle: true,
clean: true, // clean up the dist folder
dts: true, // generate dts files
minify: true,
entry: ["src/index.ts"], // include all files under src
skipNodeModulesBundle: true,
sourcemap: true,
splitting: true,
target: "es2020",
env: {
APTOS_NETWORK: process.env.APTOS_NETWORK ?? "Devnet",
ANS_TEST_ACCOUNT_PRIVATE_KEY:
process.env.ANS_TEST_ACCOUNT_PRIVATE_KEY ?? "0x37368b46ce665362562c6d1d4ec01a08c8644c488690df5a17e13ba163e20221",
ANS_TEST_ACCOUNT_ADDRESS:
process.env.ANS_TEST_ACCOUNT_ADDRESS ?? "0x585fc9f0f0c54183b039ffc770ca282ebd87307916c215a3e692f2f8e4305e82",
},
};
// Browser config, uses iife
const IIFE_CONFIG: MandatoryOptions = {
...DEFAULT_CONFIG,
format: "iife",
globalName: "aptosSDK",
outDir: "dist/browser",
platform: "browser",
splitting: false,
};
// Common.js config
const COMMON_CONFIG: MandatoryOptions = {
...DEFAULT_CONFIG,
format: "cjs",
outDir: "dist/common",
platform: "node",
};
// ESM config
const ESM_CONFIG: MandatoryOptions = {
...DEFAULT_CONFIG,
entry: ["src/**/*.ts"],
format: "esm",
outDir: "dist/esm",
platform: "node",
};
export default defineConfig([IIFE_CONFIG, COMMON_CONFIG, ESM_CONFIG]);