UNPKG

851 BMarkdownView Raw
1# babel-plugin-transform-node-env-inline
2
3Inline the `NODE_ENV` environment variable and if it's a part of a binary expression
4(eg. `process.env.NODE_ENV === "development"`) then statically evaluate and replace it.
5
6## Example
7
8**In**
9
10```javascript
11process.env.NODE_ENV === "development";
12process.env.NODE_ENV === "production";
13```
14
15**Out**
16
17```sh
18NODE_ENV=development babel in.js --plugins transform-node-env-inline
19```
20
21```javascript
22true;
23false;
24```
25
26## Installation
27
28```sh
29npm install babel-plugin-transform-node-env-inline
30```
31
32## Usage
33
34### Via `.babelrc` (Recommended)
35
36**.babelrc**
37
38```json
39{
40 "plugins": ["transform-node-env-inline"]
41}
42```
43
44### Via CLI
45
46```sh
47babel --plugins transform-node-env-inline script.js
48```
49
50### Via Node API
51
52```javascript
53require("babel-core").transform("code", {
54 plugins: ["transform-node-env-inline"]
55});
56```