I have a sapper project which contains various database secrets and such... So for local development I want to load a .env
which contains the secrets. I am aware of dotenv. How do I use dotenv to load the .env
file only on my local machine and not on my deployment in cloud run.
Rather than using the dotenv package you can use the dotenv-cli. You install it globally and modify the dev npm command and prefix it with dotenv
. The cli will locate the .env
file and then run the sapper dev
command with the environment variables set.
Add another command for production without the dotenv prefix so it uses the environment variables on the machine.