frappe_docker/frappe-bench/node_modules/babel-plugin-minify-replace
2017-07-31 15:51:51 +05:30
..
lib Final docker setup 2017-07-31 15:51:51 +05:30
.npmignore Final docker setup 2017-07-31 15:51:51 +05:30
package.json Final docker setup 2017-07-31 15:51:51 +05:30
README.md Final docker setup 2017-07-31 15:51:51 +05:30

babel-plugin-minify-replace

Configurable "search and replace" plugin. Replaces matching nodes in the tree with a given replacement node. For example you can replace process.NODE_ENV with "production".

Example

Options

[
  {
    identifierName: "__DEV__",
    replacement: {
      type: "numericLiteral",
      value: 0,
    },
  },
]

In

if (!__DEV__) {
  foo();
}
if (a.__DEV__) {
  foo();
}

Out

if (!0) {
  foo();
}
if (a.__DEV__) {
  foo();
}

Installation

$ npm install babel-plugin-minify-replace

Usage

.babelrc

// without options
{
  "plugins": ["minify-replace"]
}

// with plugins
{
  "plugins": ["minify-replace", {
    "identifierName": "__DEV__",
    "replacement": {
      "type": "booleanLiteral",
      "value": true
    }
  }]
}

Via CLI

$ babel --plugins minify-replace script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["minify-replace"]
});