-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathesbuild.config.js
60 lines (54 loc) · 1.35 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* eslint-disable @typescript-eslint/no-var-requires */
// @ts-check
const fs = require("fs/promises");
const esbuild = require("esbuild");
const plugin = require("node-stdlib-browser/helpers/esbuild/plugin");
const stdLibBrowser = require("node-stdlib-browser");
const production = process.argv.includes("--production");
/**
* @type {esbuild.BuildOptions}
*/
const commonOptions = {
entryPoints: ["./src/extension.ts"],
format: "cjs",
bundle: true,
minify: production,
sourcemap: !production,
metafile: !production,
loader: { ".html": "text" },
external: ["vscode"]
};
/**
* @type {esbuild.BuildOptions[]}
*/
const options = [
{
...commonOptions,
outfile: "out/extension.js",
platform: "node"
},
{
...commonOptions,
outfile: "out/extension-browser.js",
platform: "browser",
inject: [require.resolve("node-stdlib-browser/helpers/esbuild/shim")],
define: {
assert: "assert",
path: "path",
process: "process",
util: "util",
Buffer: "Buffer"
},
plugins: [plugin(stdLibBrowser)]
}
];
options
.filter(({ platform }) => process.argv.includes(`--${platform}`))
.forEach(async (option) => {
const result = await esbuild.build(option);
if (production) return;
await fs.writeFile(
`out/meta-${option.platform}.json`,
JSON.stringify(result.metafile)
);
});