An alternative approach to packaging for Serverless
npm install serverless-packageUnlike most, I write my serverless apps in Python.
When including third party packages, it can be quite messy, especially for the output of git status.
This approach allows me to install them into a dist/ directory using "pip install -t dist/ ..." and then .gitignore that directory.
1. Add "serverless-packages" to your plugins list.
1. Specify an artifact in your existing package config
This disables the built in packager, and enables this one.
1. Add a custom.package section
This is a map of root paths to lists of glob-all terms.
``
plugins:
- serverless-package
package:
artifact: .serverless/package.zip
custom:
package:
sources:
"./src/":
- "**" # Include everything
- "!*/.pyc" # Except the .pyc files
"./dist/":
- "**" # Include everything
- "!*/.pyc" # Except .pyc files
- "!@(dist|egg)-info/*" # Or pip's book-keeping files
`
Additionally, this adds the "package" command.
``
sls package
This will only run the serverless-package` command, not the built in packaging.