Makes package.json
variables available.in serverless.yml
, and exposes the package.json
version as its semver
components.
Install the plugin using the serverless cli
serverless plugin install -n @packt/serverless-plugin-package
Install the package in your service:
npm install --save-dev @packt/serverless-plugin-package
Then register it in your plugins array in serverless.yml
:
plugins:
- "@packt/serverless-plugin-package"
Note: Don't forget to quoe the plugin name in serverless.yml
, @
has a meaning in yml.
To reference variables from your project's package.json
.
# Becomes name: my-awesome-service-1
name: ${package:name}-${package:semver.major}
...
custom:
# Uses your description from package.json
description: ${package:description}
To reference semver
parts of your project's version
:
custom:
patchVersion: ${package:semver.patch}
minorVersion: ${package:semver.minor}
majorVersion: ${package:semver.major}