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