Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/discord/babel-plugin-define-patterns
Create constants that replace various expressions at build-time
https://github.com/discord/babel-plugin-define-patterns
babel babel-plugin loader webpack webpack-loader
Last synced: 3 months ago
JSON representation
Create constants that replace various expressions at build-time
- Host: GitHub
- URL: https://github.com/discord/babel-plugin-define-patterns
- Owner: discord
- License: mit
- Created: 2020-04-16T03:36:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T08:32:19.000Z (over 1 year ago)
- Last Synced: 2024-10-01T03:40:56.131Z (3 months ago)
- Topics: babel, babel-plugin, loader, webpack, webpack-loader
- Language: JavaScript
- Size: 182 KB
- Stars: 38
- Watchers: 10
- Forks: 6
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-define-patterns
> Create constants that replace various expressions at build-time
## Install
```sh
npm install --save-dev babel-plugin-define-patterns
```## Usage
```js
// babel.config.json
{
"plugins": [
["define-patterns", {
"replacements": {
"process.env.NODE_ENV": "production",
"typeof window": "object",
"__DEV__": true,
"require('currentBuildNumber')": 42
}
}]
]
}
```## Example
**Input:**
```js
process.env.NODE_ENV
```**Options:**
```json
{
"replacements": {
"process.env.NODE_ENV": "development"
}
}
```**Output:**
```js
"development"
```For more examples see [input.txt](./fixtures/input.txt) and
[output.txt](./fixtures/output.txt).