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

编程入门 行业动态 更新时间:2024-10-25 08:22:42

Serverless Typescript插件<a href=https://www.elefans.com/category/jswz/34/1623551.html style=将我所有的lambda函数打包到一个zip存档中"/>

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存档中

本文发布于:2024-05-06 22:58:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1753926.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:将我   函数   插件   Serverless   Typescript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!