/
build.ts
41 lines (35 loc) · 836 Bytes
/
build.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
// https://github.com/souporserious/bundling-typescript-with-esbuild-for-npm
const { build } = require("esbuild");
const { peerDependencies } = require("./package.json");
const entryPoints = ["src/index.tsx"];
const shared = {
bundle: true,
define: {
"process.env.NODE_ENV": JSON.stringify(
process.env.NODE_ENV || "development"
),
},
platform: "node",
logLevel: "info",
entryPoints,
minify: false,
sourcemap: true,
};
build({
...shared,
entryPoints: ["src/dom.tsx"],
outfile: "./dist/yith.js",
minify: process.env.NODE_ENV === "production",
});
build({
...shared,
external: ["react", "react-dom", "mirador"],
format: "cjs",
outfile: "./dist/index.cjs.js",
});
build({
...shared,
external: ["react", "react-dom", "mirador"],
format: "esm",
outfile: "./dist/index.esm.js",
});