-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
44 lines (39 loc) · 1.12 KB
/
build.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
const { execSync } = require("child_process");
const esbuild = require("esbuild");
const path = require("path");
const { Generator } = require("npm-dts");
new Generator({
entry: path.resolve(__dirname, "stories/index.ts"),
output: path.resolve(__dirname, "dist/index.d.ts"),
tsc: "--emitDeclarationOnly --project tsconfig.lib.json"
}).generate();
// Run TypeScript to generate type declarations using the new tsconfig.lib.json
execSync("tsc --emitDeclarationOnly --project tsconfig.lib.json", { stdio: "inherit" });
const context = {
logLevel: "info",
entryPoints: [path.resolve(__dirname, "stories/index.ts")],
bundle: true,
platform: "browser",
target: ["esnext"],
minify: true,
pure: ["React.createElement"],
jsx: "automatic",
loader: { ".js": "jsx" },
outdir: path.resolve(__dirname, "dist"),
sourcemap: true,
external: [
"react",
"react-dom",
"@floating-ui/react",
"@headlessui/react",
"@headlessui/tailwindcss",
"@heroicons/react",
"@tabler/icons",
"@tabler/icons-react",
"classnames",
"react-icons"
],
format: "esm"
};
// Build script using esbuild
esbuild.build(context).catch(() => process.exit(1));