babel-plugin-define-patterns

1.0.0 • Public • Published

babel-plugin-define-patterns

Create constants that replace various expressions at build-time

Install

npm install --save-dev babel-plugin-define-patterns

Usage

// babel.config.json
{
  "plugins": [
    ["define-patterns", {
      "replacements": {
        "process.env.NODE_ENV": "production",
        "typeof window": "object",
        "__DEV__": true,
        "require('currentBuildNumber')": 42
      }
    }]
  ]
}

Example

Input:

process.env.NODE_ENV

Options:

{
    "replacements": {
        "process.env.NODE_ENV": "development"
    }
}

Output:

"development"

For more examples see input.txt and output.txt.

/babel-plugin-define-patterns/

    Package Sidebar

    Install

    npm i babel-plugin-define-patterns

    Weekly Downloads

    4,650

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    9.86 kB

    Total Files

    7

    Last publish

    Collaborators

    • samschlegel
    • birarda
    • faulty
    • discord_kevin
    • discord_npmjs
    • justinbeckwith
    • thejameskyle