add more plugins, rename some
This commit is contained in:
18
packages/babel-plugin-transform-node-env-inline/src/index.js
Normal file
18
packages/babel-plugin-transform-node-env-inline/src/index.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export default function ({ types: t }) {
|
||||
return {
|
||||
visitor: {
|
||||
MemberExpression(path) {
|
||||
if (path.matchesPattern("process.env.NODE_ENV")) {
|
||||
path.replaceWith(t.valueToNode(process.env.NODE_ENV));
|
||||
|
||||
if (path.parentPath.isBinaryExpression()) {
|
||||
var evaluated = path.parentPath.evaluate();
|
||||
if (evaluated.confident) {
|
||||
path.parentPath.replaceWith(t.valueToNode(evaluated.value));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user