1 | # babel-plugin-transform-node-env-inline
|
2 |
|
3 | Inline 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
|
11 | process.env.NODE_ENV === "development";
|
12 | process.env.NODE_ENV === "production";
|
13 | ```
|
14 |
|
15 | **Out**
|
16 |
|
17 | ```sh
|
18 | $ NODE_ENV=development babel in.js --plugins transform-node-env-inline
|
19 | ```
|
20 |
|
21 | ```javascript
|
22 | true;
|
23 | false;
|
24 | ```
|
25 |
|
26 | ## Installation
|
27 |
|
28 | ```sh
|
29 | $ npm 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
|
47 | $ babel --plugins transform-node-env-inline script.js
|
48 | ```
|
49 |
|
50 | ### Via Node API
|
51 |
|
52 | ```javascript
|
53 | require("babel-core").transform("code", {
|
54 | plugins: ["transform-node-env-inline"]
|
55 | });
|
56 | ```
|