Name: babel-plugin-transform-define
Owner: Formidable
Description: Compile time code replacement for babel similar to Webpack's DefinePlugin
Created: 2016-03-19 23:18:20.0
Updated: 2018-01-13 09:23:51.0
Pushed: 2017-11-27 15:54:41.0
Size: 38
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
install babel-plugin-transform-define
.babelrc
lugins": [
["transform-define", {
"process.env.NODE_ENV": "production",
"typeof window": "object"
}]
.babelrc
lugins": [
["transform-define", "./path/to/config/file.js"]
Note: Paths are relative to process.cwd()`
babel-plugin-transform-define
can transform certain types of code as a babel transformation.
Identifiers
.babelrc
lugins": [
["transform-define", {
"VERSION": "1.0.0",
}]
Source Code
ION;
ow.__MY_COMPANY__ = {
rsion: VERSION
Output Code
.0";
ow.__MY_COMPANY__ = {
rsion: "1.0.0"
Member Expressions
.babelrc
lugins": [
["transform-define", {
"process.env.NODE_ENV": "production"
}]
Source Code
process.env.NODE_ENV === "production") {
nsole.log(true);
Output Code
true) {
nsole.log(true);
Unary Expressions
.babelrc
lugins": [
["transform-define", {
"typeof window": "object"
}]
Source Code
of window;
of window === "object";
Output Code
ect';
;