I'm using the following as a custom serverless-dotenv-plugin
plugin configuration:
custom:
dotenv:
path: .env-${opt:stage, 'local'}
But what I'm really trying to get is that the environment be loaded from .env
file when I give no arguments and .env.staging
file when I use staging
as a CLI argument.
I don't know how this can be reflected in path
above. Any help please?
I am the author of serverless-dotenv-plugin. There was a logistical problem when trying to dynamically load env files from the provider or other options. I have since updated the plugin however so that you can dynamically load env files based what environment is set.
For example, if you run "NODE_ENV=production sls deploy" it will look for a file called .env.production. If it is not found, it will fallback to .env.
See the README for more detail https://github.com/infrontlabs/serverless-dotenv-plugin