zqjimlove / babel-plugin-transform-define-vars

Allows you to create global constants which can be configured at compile time

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-transform-define-vars

The plugin allows you to create global constants which can be configured at compile time with Babel.

Example

// Babel config
{
  plugins:[
    ['transform-define-vars', 
      {
        hello:'world'
      }
    ]
  ]
}

// In
var hello = process.env.hello;

var hello2 = process.env['hello'];

if('wordl' === process.env.hello){...}


// Out
var hello = 'world'

var hello2 = 'world'

if(true){...}

Installation

npm install --save-dev @babel/babel-plugin-transform-define-vars

Usage

{
  'plugins': [
    ['transform-define-vars', 
      {
        hello:'world'
      }
    ]
  ]
}

About

Allows you to create global constants which can be configured at compile time


Languages

Language:JavaScript 100.0%