Netlify Build plugin that reads environment variables from .env file
You can just add this plugin to your Netlify configuration by including in your config file like this:
# netlify.toml
[[plugins]]
package = "netlify-plugin-dotenv"
Note: Unfortunatelly this plugin wasn't accepted to be part of the official Netlify plugins so you can't install it from the dashboard. And you have to install it as dependency of your project by adding it into
package.json
file.
name | default | description |
---|---|---|
variable | none | You can specify what environment variable will be used for resolving the file. If you specify BRANCH the filename will become .env.${process.env.BRANCH} . |
# netlify.toml
[[plugins]]
package = "netlify-plugin-dotenv"
[plugins.inputs]
variable = "BRANCH"
This plugin will read and parse files in the following order:
.env.master
forBRANCH=master
and variable = BRANCH.env
Using this order will result in overwriting environment variables from bottom up.
So if you have some default variable FOO
defined in both .env
and .env.production
it will resolve using variable from the latter one.