我的服务结构:
-MyService
-common
-node_modules
-functions_folder
-Function1.js
-Function2.js
-Function3.js
yaml文件:
service: MyService
provider:
name: aws
runtime: nodejs6.10
stage: dev
functions:
Function1:
handler: functions_folder/Function1.handler
memorySize: 512
timeout: 10
Function2:
handler: functions_folder/Function2.handler
memorySize: 512
timeout: 10
Function2:
handler: functions_folder/Function3.handler
memorySize: 512
timeout: 10
当我正在部署时,我有3个不同的lambda函数,但每个函数都包含Function1.js,Function2.js,Function3.js。
有人可以解释一下如何排除Lambda不需要的文件吗?
答案 0 :(得分:3)
经过一段时间的研究,我找到了解决方案。 所以这就是:
service: MyService
package:
individually: true
exclude:
- ./**
include:
- common/**
- node_modules/**
provider:
name: aws
runtime: nodejs6.10
stage: dev
memorySize: 512
timeout: 10
functions:
Function1:
handler: functions_folder/Function1.handler
package:
include:
- functions_folder/Function1.js
Function2:
handler: functions_folder/Function2.handler
package:
include:
- functions_folder/Function2.js
Function2:
handler: functions_folder/Function3.handler
package:
include:
- functions_folder/Function3.js
因此,您可以在包部分中看到我添加了包含/排除部分, 首先,我排除了所有文件,然后我将包含2个所需的文件夹" common"和" node_modules"。在此之后,我还使用include命令来添加所需的文件。