如果您在 AWS CodeBuild 中使用 AWS Serverless Application Model (SAM) 和 esbuild 方法时遇到问题,可以尝试以下
phases:
install:
runtime-versions:
nodejs: 14.x
commands:
- npm install
build:
commands:
- npx webpack
artifacts:
files:
- '**/*'
如果您已经正确指定了这些文件,请继续进行以下步骤。
npm install esbuild
npm install
npm install typescript
npx esbuild ./src/index.ts --bundle --outfile=./dist/index.js
env:
AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
请注意,这些命令需要在 AWS CodeBuild 中设置环境变量,例如使用 AWS Systems Manager Parameter Store。
通过按照上述步骤进行检查和设置,您应该能够成功使用 AWS CodeBuild、SAM 和 esbuild 方法进行构建。