英文:
Excluding @aws-sdk packages from the output of serverless package command in Serverless Framework
问题
I am using the Serverless Framework to deploy my AWS Lambda functions. I want to exclude the "@aws-sdk" packages from the build file generated by the serverless package command. I have tried using both the exclude property and forceExclude option in my serverless.yml file, but the "@aws-sdk" packages still appear in the build file.
Here's my current configuration in serverless.yml:
service: my-service
provider:
name: aws
runtime: nodejs14.x
package:
exclude:
- node_modules/**
# I have also tried using forceExclude:
# forceExclude:
# - node_modules/aws-sdk/**
functions:
# function configurations...
I have double-checked that the exclude
property is correctly set, and I have restarted the deployment process multiple times, but the @aws-sdk
packages keep showing up in the build file.
Is there any other approach or configuration option that I'm missing? How can I effectively exclude
the @aws-sdk
packages from the output of the serverless package command? Any help would be appreciated. Thank you!
英文:
I am using the Serverless Framework to deploy my AWS Lambda functions. I want to exclude the "@aws-sdk" packages from the build file generated by the serverless package command. I have tried using both the exclude property and forceExclude option in my serverless.yml file, but the "@aws-sdk" packages still appear in the build file.
Here's my current configuration in serverless.yml:
service: my-service
provider:
name: aws
runtime: nodejs14.x
package:
exclude:
- node_modules/**
# I have also tried using forceExclude:
# forceExclude:
# - node_modules/aws-sdk/**
functions:
# function configurations...
I have double-checked that the exclude
property is correctly set, and I have restarted the deployment process multiple times, but the @aws-sdk
packages keep showing up in the build file.
Is there any other approach or configuration option that I'm missing? How can I effectively exclude
the @aws-sdk
packages from the output of the serverless package command? Any help would be appreciated. Thank you!
答案1
得分: 2
默认情况下,serverless-esbuild会排除aws-sdk
的第2版。如果您使用的是第3版,文件夹名称不同。它是@aws-sdk
,因此您必须在配置中添加如下内容:
custom:
esbuild:
exclude:
- "@aws-sdk"
英文:
By default, serverless-esbuild excludes aws-sdk
version 2. If you are using version 3, the folder name is different. It is @aws-sdk
, so you must add this on your configuration
custom:
esbuild:
exclude:
- "@aws-sdk"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论