Add AWS Lambda Bundle Size Optimization Guide and update build scripts for Prisma layer
This commit is contained in:
@@ -7,9 +7,9 @@ provider:
|
||||
versionFunctions: false
|
||||
memorySize: 512
|
||||
# Apply Prisma layer to all functions
|
||||
# Use the published layer version ARN (works for full deploy and `deploy function`)
|
||||
# Reference the layer defined in this stack using CloudFormation Ref
|
||||
layers:
|
||||
- ${cf:${self:service}-${sls:stage}.PrismaLambdaLayerQualifiedArn}
|
||||
- !Ref PrismaLambdaLayer
|
||||
apiGateway:
|
||||
binaryMediaTypes:
|
||||
- '*/*'
|
||||
@@ -68,14 +68,32 @@ build:
|
||||
sourcemap: false
|
||||
target: node20
|
||||
platform: node
|
||||
# Mark as external so they're not bundled into the JS
|
||||
external:
|
||||
# These are provided by the Prisma layer
|
||||
- '@prisma/client'
|
||||
- '@prisma/adapter-pg'
|
||||
- '.prisma/client'
|
||||
- '.prisma'
|
||||
- 'pg'
|
||||
- '@aws-sdk/*'
|
||||
- '@smithy/*'
|
||||
- '@aws-crypto/*'
|
||||
# Exclude prevents npm install of these packages in the zip
|
||||
exclude:
|
||||
- 'aws-sdk'
|
||||
- '@aws-sdk/*'
|
||||
- '@smithy/*'
|
||||
- '@aws-crypto/*'
|
||||
- '@prisma/client'
|
||||
- '@prisma/adapter-pg'
|
||||
- '.prisma'
|
||||
- '.prisma/client'
|
||||
- 'pg'
|
||||
exclude:
|
||||
- 'aws-sdk'
|
||||
- 'pg-*'
|
||||
- 'postgres-*'
|
||||
- 'pgpass'
|
||||
- 'split2'
|
||||
- 'xtend'
|
||||
|
||||
# Define layers
|
||||
layers:
|
||||
@@ -91,6 +109,8 @@ package:
|
||||
individually: true
|
||||
patterns:
|
||||
- '!node_modules/**'
|
||||
- '!node_modules/@prisma/**'
|
||||
- '!node_modules/.prisma/**'
|
||||
- '!**/*.test.js'
|
||||
- '!**/*.spec.js'
|
||||
- '!**/test/**'
|
||||
|
||||
Reference in New Issue
Block a user