babel-plugin-global-define
The GlobalDefine plugin allows you to create global constants which is similar to Webpack's DefinePlugin.
Last updated 8 years ago by zheng_refn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install babel-plugin-global-define 
SYNC missed versions from official npm registry.

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

{
  "plugins": [
    ["global-define", {
      "__ENV__": "production",
    }]
  ]
}

Node API

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

Example

In

const hosts = {
    development: 'https://test.github.com/',
    production: 'https://www.github.com/'
}
const currentHost = hosts[__ENV__]

Out

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

Current Tags

  • 1.0.3                                ...           latest (8 years ago)

4 Versions

  • 1.0.3                                ...           8 years ago
  • 1.0.2                                ...           8 years ago
  • 1.0.1                                ...           8 years ago
  • 1.0.0                                ...           8 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 3
Last Month 4
Dependencies (0)
None
Dev Dependencies (5)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |