babel-plugin-transform-define
Compile time code replacement for babel similar to Webpack's DefinePlugin
Quick Start
npm install babel-plugin-transform-define
.babelrc
.babelrc
Note: Paths are relative to `process.cwd()``
Reference Documentation
babel-plugin-transform-define
can transform certain types of code as a babel transformation.
Identifiers
.babelrc
Source Code
VERSION; window__MY_COMPANY__ = version: VERSION;
Output Code
"1.0.0"; window__MY_COMPANY__ = version: "1.0.0";
Member Expressions
.babelrc
Source Code
if processenvNODE_ENV === "production" console;
Output Code
if true console;
Unary Expressions
.babelrc
Source Code
typeof window;typeof window === "object";
Output Code
'object';true;