-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild-browser.cjs
46 lines (44 loc) · 1.23 KB
/
build-browser.cjs
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
const esbuild = require('esbuild');
const { polyfillNode } = require('esbuild-plugin-polyfill-node');
const globalsPlugin = require('esbuild-plugin-globals');
const dotenv = require('dotenv');
const envObj = dotenv.config().parsed;
const build = async () => {
try {
await esbuild
.build({
entryPoints: ['./out/extension-browser.js'],
bundle: true,
outfile: 'extension.browser.js',
globalName: 'greyscript',
sourcemap: false,
minify: true,
minifyWhitespace: true,
minifyIdentifiers: true,
minifySyntax: true,
target: 'ESNext',
platform: 'browser',
treeShaking: true,
format: 'cjs',
external: [
'vscode'
],
define: {
'process.env.NODE_ENV': '"production"',
...Object.entries(envObj).reduce((result, [key, value]) => {
result[`process.env.${key}`] = `"${value}"`;
return result;
}, {})
},
plugins: [
polyfillNode({
globals: false
})
]
});
} catch (err) {
console.error('Failed building project', { err });
process.exit(1);
}
};
build();