babel-plugin-global-define

The GlobalDefine plugin allows you to create global constants which is similar to Webpack's DefinePlugin.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-global-define
1.0.35 years ago5 years agoMinified + gzip package size for babel-plugin-global-define in KB

Readme

babel-plugin-global-define
The GlobalDefine plugin allows you to create global constants which is similar to Webpack's DefinePlugin

Usage

install

npm i babel-plugin-global-define --save-dev
``` 
### .babelrc
``` javascript
{
  "plugins": [
    ["global-define", {
      "__ENV__": "production",
    }]
  ]
}

Node API

require("babel-core").transform("foo();", {
    plugins: [
        ["global-define", { "__ENV__": "production" }]
    ]}
})

Example

In

```javascript const hosts = {
development: 'https://test.github.com/',
production: 'https://www.github.com/'
} const currentHost = hostsENV ````

Out

```javascript const hosts = {
development: 'https://test.github.com/',
production: 'https://www.github.com/'
} const currentHost = hosts"production" ````