跳到主要内容

babel-plugin-transform-node-env-inline

Example

In

JavaScript
process.env.NODE_ENV === "development";
process.env.NODE_ENV === "production";

Out

Shell
NODE_ENV=development babel in.js --plugins transform-node-env-inline
JavaScript
true;
false;

Installation

npm install babel-plugin-transform-node-env-inline --save-dev

Usage

babel.config.json
{
"plugins": ["transform-node-env-inline"]
}

Via CLI

Shell
babel --plugins transform-node-env-inline script.js

Via Node API

JavaScript
require("@babel/core").transformSync("code", {
plugins: ["transform-node-env-inline"],
});