UNPKG

liferay-npm-bundler-preset-reactjs

Version:

liferay npm bundler preset react

25 lines (21 loc) 566 B
"use strict"; module.exports = function ({ types: t }) { return { name: "transform-node-env-inline", visitor: { MemberExpression(path) { if (path.matchesPattern("process.env.NODE_ENV")) { path.replaceWith(t.valueToNode(process.env.NODE_ENV)); if (path.parentPath.isBinaryExpression()) { const evaluated = path.parentPath.evaluate(); if (evaluated.confident) { path.parentPath.replaceWith(t.valueToNode(evaluated.value)); } } } } } }; };