最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

Serverless Typescript插件将我所有的lambda函数打包到一个zip存档中

IT培训 admin 15浏览 0评论

Serverless Typescript插件将我所有的lambda函数打包到一个zip存档中

下面是我的serverless.yml


service: serverless-typescript-example
provider:
  name: aws

package:
  individually: true

plugins:
  - serverless-plugin-typescript

functions: 
  hello1:
    handler: hello1/src/index.handler
  hello2:
    handler: hello/src/index.handler

并且我的文件夹结构如下所示

hello1
 --index.ts
 --package.json
hello2
 --index.ts
 --package.json
package.json
serverless.yml

在run sls程序包中,它将在.serverless文件夹中创建两个zip存档,名称分别为hello1.zip和hello2.zip。解压缩后,两个文件夹都具有相同的内容,即带有node_modules的hello1和hello2。

有没有解决此问题的选项,我们可以将.zip文件放在相应的函数文件夹中,我的意思是hello1中的hello1.zip和hello2中的hello2.zip

回答如下:我还没有使用serverless-plugin-typescript,但我们使用了serverless-webpack,它做的很整洁。由于它使用webpack捆绑,因此大大减少了lambda大小。

还有一个使用serverless-webpack插件的无服务器创建模板。

serverless create --template aws-nodejs-typescript

zip文件默认放置在.serverless文件夹中。 

Serverless Typescript插件将我所有的lambda函数打包到一个zip存档中

下面是我的serverless.yml


service: serverless-typescript-example
provider:
  name: aws

package:
  individually: true

plugins:
  - serverless-plugin-typescript

functions: 
  hello1:
    handler: hello1/src/index.handler
  hello2:
    handler: hello/src/index.handler

并且我的文件夹结构如下所示

hello1
 --index.ts
 --package.json
hello2
 --index.ts
 --package.json
package.json
serverless.yml

在run sls程序包中,它将在.serverless文件夹中创建两个zip存档,名称分别为hello1.zip和hello2.zip。解压缩后,两个文件夹都具有相同的内容,即带有node_modules的hello1和hello2。

有没有解决此问题的选项,我们可以将.zip文件放在相应的函数文件夹中,我的意思是hello1中的hello1.zip和hello2中的hello2.zip

回答如下:我还没有使用serverless-plugin-typescript,但我们使用了serverless-webpack,它做的很整洁。由于它使用webpack捆绑,因此大大减少了lambda大小。

还有一个使用serverless-webpack插件的无服务器创建模板。

serverless create --template aws-nodejs-typescript

zip文件默认放置在.serverless文件夹中。 
发布评论

评论列表 (0)

  1. 暂无评论