-
Notifications
You must be signed in to change notification settings - Fork 1
/
esbuild.config.js
38 lines (36 loc) · 1.17 KB
/
esbuild.config.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
/* eslint-disable no-unused-vars */
import console from "node:console";
import { exit } from "node:process";
import { build as esbuild } from "esbuild";
/** Helper function for multiple builds */
const build = async function(name, options) {
try {
const { outputFiles, metafile, mangleCache, ...buildResult } = await esbuild({
bundle: true,
minify: true,
target: "es2020",
banner: {
js: "/* This is a bundled file generated by esbuild\nIf you want to view the source, please visit the github repository */",
},
...options,
});
console.log(`built ${name}:`, buildResult);
} catch (error) {
console.error(`building ${name} failed:`, error);
exit(1);
}
};
(async function() {
await build("minified browser esm", {
entryPoints: ["./src/index.browser.js"],
format: "esm",
platform: "browser",
outfile: "./dist/index.browser.js",
});
await build("minified node cjs", {
entryPoints: ["./src/index.cjs.js"],
format: "cjs",
platform: "node",
outfile: "./dist/index.cjs",
});
})();