-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ts
More file actions
41 lines (34 loc) · 875 Bytes
/
build.ts
File metadata and controls
41 lines (34 loc) · 875 Bytes
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
import { build, BuildOptions } from 'esbuild';
import { parseEnvVarsAsKeyVal } from './src/utils/env';
import { defined } from './src/defined';
import pkgJson from './package.json';
import type { Defined } from './src/defined';
const external = [...Object.keys(pkgJson.dependencies)];
const define = parseEnvVarsAsKeyVal<Defined>({
defined,
});
const main = async () => {
const buildOptions: BuildOptions = {
entryPoints: ['./src/index.ts'],
define,
bundle: true,
platform: 'browser',
target: 'esnext',
outfile: 'dist/bundle.js',
format: 'esm',
sourcemap: true,
external,
minify: true,
loader: {
'.css': 'text',
},
};
try {
await build(buildOptions);
} catch (error) {
console.error('👹 Oops! Failed to bundle for some reason...');
console.error(error);
process.exit(1);
}
};
main();