Miss any of our Open RFC calls?Watch the recordings here! »

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.

Install

npm i babel-plugin-define-patterns

DownloadsWeekly Downloads

1,500

Version

1.0.0

License

MIT

Unpacked Size

9.86 kB

Total Files

7

Last publish

Collaborators

  • avatar
  • avatar
  • avatar
  • avatar