Socket
Socket
Sign inDemoInstall

netlify-plugin-contextual-env

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    netlify-plugin-contextual-env

A Netlify plugin to override ENV vars based on a branch or context


Version published
Weekly downloads
546
increased by13.75%
Maintainers
1
Install size
9.97 kB
Created
Weekly downloads
 

Readme

Source

netlify-plugin-contextual-env

This plugin swaps out ENV vars on Netlify at build time. Here's how it works:

Say you have an ENV in your API code called DATABASE_URL. If you use this plugin, you'll be able to override that value based on a Context or Branch name.

For example:

  • A staging branch, would automatically set DATABASE_URL to the value of STAGING_DATABASE_URL if it exists.
  • A production context would automatically set DATABASE_URL to the value of PRODUCTION_DATABASE_URL if it exists.
  • A deploy-preview context (used for Pull Requests) would automatically set DATABASE_URL to the value of DEPLOY_PREVIEW_DATABASE_URL if it exists.

This allows you to have per-environment or per-context environment variables, without exposing those variables in your netlify.toml config.

If you'd rather use a suffix rather than the default prefix configuration, pass suffix to the inputs below.

For the examples above, it would use the values DATABASE_URL_STAGING, DATABASE_URL_PRODUCTION, and DATABASE_URL_DEPLOY_PREVIEW respectively.

image

Usage

Add the plugin

Add a [[plugins]] entry to your netlify.toml file:

[[plugins]]
package = 'netlify-plugin-env'
  [plugins.inputs]
  mode = 'prefix'
namedescriptiondefault
modeThe way to append the context or branch name (prefix or suffix)prefix

Keywords

FAQs

Last updated on 24 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc