Can I create multiple contexts in netlify.toml?

Hi I am using netlify like this :

[context.production]
  command = "npm run deploy"
  environment ={ APP_ENV = "production" }

[context.deploy-preview]
  command = "npm run deploy"

[context.develop]
  command = "echo 'context is develop' && npm run deploy"
  base = "develop"
  environment ={ APP_ENV = "production" }

[context.branch-deploy]
  command = "npm run deploy"

But I want to create [context.develop] under the [context.deploy-preview] such as [context.deploy-preview && context.develop], because I need APP_ENV variable in only production but also deploy-preview from devlop branch.

How can I use like that? anyone help!

Hi there,

Not possible - you need to multiply define the environment in both contexts.

You could though, create one default:

[build]
  environment = { APP_ENV = "production" }

which would apply to EVERY context UNLESS you override such as:

[context.develop]
  environment = { APP_ENV = "development" }
1 Like