Reputation: 1827
I have been struggling with this thing. Following is my directory structure:
lib
├── dir
│ ├── DirButNotOneSubdir
│ │ ├── DirIdontWantBecauseTheSizeIsTooLarge
│ │ └── DirIwant
│ ├── DirIdontWantBecauseTheSizeIsTooLarge
│ └── DirIwant
├── lambda1.py
└── lambda2.py
There are some directories inside the sub-directories I require but others not. For simplicity, I have reduced the number of directories and therefore I cannot exclude everything one by one. Here is something I did in serverless.yml:
package:
excludeDevDependencies: true
exclude:
- "*"
- "*/**"
- lib/dir/DirIdontWantBecauseTheSizeIsTooLarge
- lib/dir/DirButNotOneSubdir/DirIdontWantBecauseTheSizeIsTooLarge
include:
- lib/*
So when I checked inside my zip file in .serverless lib/dir was completely ignored :( and only solution I can think of right now is to explicitly mention each directory to be included. Has anyone tackled this issue.
Also including everything first and then excluding some directories also doesn't seem to work.
Note: This is one legacy C-Code building things up so it would be really harsh to change structure from how things are right now.
Upvotes: 0
Views: 586
Reputation: 8064
Try this:
package:
exclude:
- '*/**'
include:
- 'lib/**'
- '!./lib/dir/DirIdontWantBecauseTheSizeIsTooLarge'
- '!./lib/dir/DirButNotOneSubdir/DirIdontWantBecauseTheSizeIsTooLarge'
It should include everything under lib/
except the files you tell it not to. By using !
, you can mark files and directories to omit during the include step.
Upvotes: 1