babel-plugin-transform-string-literal-replace

1.0.2 • Public • Published

string-literal-replace

A simple Babel plugin to transform source code by finding and replacing string literals with other values.

Use Case

Inject constants and other snippets into source code.

Usage

.babelrc

{
  "plugins": [
    ["transform-string-literal-replace", {
      "Sebastiaan": "Seb",
      "SOME_MESSAGE": 1234567890
    }]
  ]
}
import {transform} from 'babel-core'
const input = `var name = 'Sebastiaan';alert('SOME_MESSAGE');`
const output = transform(input)
// -> `var name = 'Seb';alert(1234567890);`

Options

pattern

An Object or Map containing strings to replace with values that are either String, Number, Boolean, or null.

Dependencies (0)

    Dev Dependencies (7)

    Package Sidebar

    Install

    npm i babel-plugin-transform-string-literal-replace

    Weekly Downloads

    52

    Version

    1.0.2

    License

    ISC

    Last publish

    Collaborators

    • seb