-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
45 lines (42 loc) · 981 Bytes
/
build.mjs
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
import * as esbuild from 'esbuild';
import { compile } from 'ejs';
import { readFile, writeFile } from 'fs/promises';
const ejsPlugin = {
name: 'ejs',
setup(build) {
build.onLoad({ filter: /\.ejs$/ }, async ({ path }) => {
const ejs = await readFile(path, 'utf-8');
const template = compile(ejs, {
filename: path,
client: true,
strict: true,
async: true,
}).toString();
return {
loader: 'js',
contents: 'export default ' + template,
};
});
},
};
const build = await esbuild.build({
outdir: 'dist',
entryPoints: ['src/index.ts'],
bundle: true,
minify: false,
sourcemap: true,
write: true,
platform: 'node',
external: ['@aws-sdk'],
legalComments: 'linked',
metafile: true,
target: 'node20',
plugins: [ejsPlugin],
format: 'esm',
outExtension: {
'.js': '.mjs',
},
});
await writeFile('meta.json', JSON.stringify(build.metafile), {
encoding: 'utf-8',
});