To Nha Notes | Jan. 7, 2025, 11:44 a.m.
If you're facing esbuild bundling failures in AWS CodePipeline and it defaults to Docker builds, follow these steps to force the use of esbuild:
Install esbuild: In your AWS CDK code, add the command to install the latest esbuild version globally during the build process:
npm install -g esbuild
Update the buildspec.yml file: Manually update the buildspec.yml in the AWS Console the first time to ensure bundling works:
version: 0.2 phases: install: runtime-versions: nodejs: 14 commands: - npm install -g esbuild build: commands: - esbuild src/index.js --bundle --outfile=dist/bundle.js artifacts: files: - dist/**
Automatic future builds: After the first successful build, CodePipeline will use the esbuild installation defined in your CDK code for all future builds, eliminating the need for Docker-based builds.