Tencent-SCF - Packaging
Package CLI Command
Using the Serverless CLI tool, you can package your project without deploying it to Tencent Cloud. This is best used with CI / CD workflows to ensure consistent deployable artifacts.
Running the following command will build and save all of the deployment artifacts in the service's .serverless directory:
However, you can also use the --package option to add a destination path and Serverless will store your deployment artifacts there (./my-artifacts in the following case):
serverless package --package my-artifacts
Sometimes you might like to have more control over your function artifacts and how they are packaged.
You can use the
exclude configuration for more control over the packaging process.
Exclude / include
Exclude and include allows you to define globs that will be excluded / included from the resulting artifact. If you wish to
include files you can use a glob pattern prefixed with
! such as
exclude or the dedicated
Serverless will run the glob patterns in order.
At first it will apply the globs defined in
exclude. After that it'll add all the globs from
include. This way you can always re-include
previously excluded files and directories.
By default, serverless will exclude the following patterns:
and the serverless configuration file being used (i.e.
Exclude all node_modules but then re-include a specific modules (in this case node-fetch) using
package: exclude: - node_modules/** - '!node_modules/node-fetch/**'
Exclude all files but
package: patterns: - '!src/**' - src/function/handler.js
Note: Don't forget to use the correct glob syntax if you want to exclude directories
exclude: - tmp/** - .git/**