-
Notifications
You must be signed in to change notification settings - Fork 0
/
esbuild.config.ts
45 lines (37 loc) · 997 Bytes
/
esbuild.config.ts
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 esbuild from 'esbuild'
import { readFileSync } from 'fs'
import { join } from 'path'
import { yamlParse } from 'yaml-cfn'
interface IAwsResource {
Type: string
}
interface ILambdaFunction extends IAwsResource {
Properties: {
CodeUri: string
}
}
const lambdasPath = 'src/lambdas'
const { Resources } = yamlParse(
readFileSync(join(__dirname, 'template.yaml'), 'utf-8')
)
const awsResources = Object.values(Resources) as IAwsResource[]
const lambdas = awsResources.filter(
(resource) => resource.Type === 'AWS::Serverless::Function'
) as ILambdaFunction[]
const entries = lambdas.map((lambda) => {
const lambdaName = lambda.Properties.CodeUri.split('/')[1]
return `./${lambdasPath}/${lambdaName}/handler.ts`
})
esbuild
.build({
bundle: true,
entryPoints: entries,
logLevel: 'info',
minify: true,
platform: 'node',
outdir: 'dist',
sourcesContent: false,
sourcemap: 'inline',
target: 'es2022'
})
.catch(() => process.exit(1))