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.

Package Sidebar

Install

npm i babel-plugin-define-patterns

Weekly Downloads

4,901

Version

1.0.0

License

MIT

Unpacked Size

9.86 kB

Total Files

7

Last publish

Collaborators

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