Cli: support local environment variables and dev-specific settings in netlify.toml, with optional context flag

Created on 17 Apr 2019  路  3Comments  路  Source: netlify/cli

@davidwells already has a prototype of this.

related:

dev

Most helpful comment

@DavidWells Is there any more progress on it? I鈥檇 love to see this feature implemented 馃ぉ

All 3 comments

@DavidWells Is there any more progress on it? I鈥檇 love to see this feature implemented 馃ぉ

yeah hope it doesn't sound too harsh but netlify dev is pretty useless in my case if I have to use the admin UI to change environment variables.

Another way to go about it is to check if the environment variables exist already and only use the admin UI ones if they don't.

Is there a workaround someone is aware of?

Edit:
Using this in the meanwhile

const env = require('dotenv').config()
console.log(`dotenv keys: ${Object.keys(env.parsed).join(', ') || 'nothing in .env'}`)
for (let k in env.parsed) {
  process.env[k] = env.parsed[k]
}

As a workaround, set your variable in the UI to the value you want it to be while developing, which Netlify Dev will use. Then use netlify.toml to set up other contexts, which will override the ones in the UI when needed.

[context.production.environment]
  MY_ENV = "something for prod"
Was this page helpful?
0 / 5 - 0 ratings