Include/Exlude 目录控制 AWS Lambda 大小的方法无服务器
Way to Include/Exlude Directories Controlling AWS Lambda Size Serverless
我一直在为这件事苦苦挣扎。以下是我的目录结构:
lib
├── dir
│ ├── DirButNotOneSubdir
│ │ ├── DirIdontWantBecauseTheSizeIsTooLarge
│ │ └── DirIwant
│ ├── DirIdontWantBecauseTheSizeIsTooLarge
│ └── DirIwant
├── lambda1.py
└── lambda2.py
我需要的子目录中有一些目录,但其他的不需要。为简单起见,我减少了目录的数量,因此我不能一一排除所有内容。这是我在 serverless.yml:
中所做的事情
package:
excludeDevDependencies: true
exclude:
- "*"
- "*/**"
- lib/dir/DirIdontWantBecauseTheSizeIsTooLarge
- lib/dir/DirButNotOneSubdir/DirIdontWantBecauseTheSizeIsTooLarge
include:
- lib/*
因此,当我在 .serverless 中查看我的 zip 文件时,lib/dir 被完全忽略了 :( 我现在能想到的唯一解决方案是明确提及要包含的每个目录。有没有人解决过这个问题.
同样先包含所有内容然后排除某些目录似乎也不起作用。
注意:这是一个遗留的 C 代码构建的东西,所以改变现在的结构真的很苛刻。
试试这个:
package:
exclude:
- '*/**'
include:
- 'lib/**'
- '!./lib/dir/DirIdontWantBecauseTheSizeIsTooLarge'
- '!./lib/dir/DirButNotOneSubdir/DirIdontWantBecauseTheSizeIsTooLarge'
它应该包括 lib/
下的所有内容,但您告诉它不要的文件除外。通过使用 !
,您可以标记要在包含步骤中忽略的文件和目录。
我一直在为这件事苦苦挣扎。以下是我的目录结构:
lib
├── dir
│ ├── DirButNotOneSubdir
│ │ ├── DirIdontWantBecauseTheSizeIsTooLarge
│ │ └── DirIwant
│ ├── DirIdontWantBecauseTheSizeIsTooLarge
│ └── DirIwant
├── lambda1.py
└── lambda2.py
我需要的子目录中有一些目录,但其他的不需要。为简单起见,我减少了目录的数量,因此我不能一一排除所有内容。这是我在 serverless.yml:
中所做的事情package:
excludeDevDependencies: true
exclude:
- "*"
- "*/**"
- lib/dir/DirIdontWantBecauseTheSizeIsTooLarge
- lib/dir/DirButNotOneSubdir/DirIdontWantBecauseTheSizeIsTooLarge
include:
- lib/*
因此,当我在 .serverless 中查看我的 zip 文件时,lib/dir 被完全忽略了 :( 我现在能想到的唯一解决方案是明确提及要包含的每个目录。有没有人解决过这个问题.
同样先包含所有内容然后排除某些目录似乎也不起作用。
注意:这是一个遗留的 C 代码构建的东西,所以改变现在的结构真的很苛刻。
试试这个:
package:
exclude:
- '*/**'
include:
- 'lib/**'
- '!./lib/dir/DirIdontWantBecauseTheSizeIsTooLarge'
- '!./lib/dir/DirButNotOneSubdir/DirIdontWantBecauseTheSizeIsTooLarge'
它应该包括 lib/
下的所有内容,但您告诉它不要的文件除外。通过使用 !
,您可以标记要在包含步骤中忽略的文件和目录。