https://github.com/fakundo/esbuild-plugin-replace-regex
Simple esbuild plugin for replacing file content while bundling
https://github.com/fakundo/esbuild-plugin-replace-regex
esbuild plugin regex replace
Last synced: 6 months ago
JSON representation
Simple esbuild plugin for replacing file content while bundling
- Host: GitHub
- URL: https://github.com/fakundo/esbuild-plugin-replace-regex
- Owner: fakundo
- Created: 2022-08-12T22:21:37.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-12T22:41:17.000Z (over 3 years ago)
- Last Synced: 2025-06-24T05:52:22.760Z (7 months ago)
- Topics: esbuild, plugin, regex, replace
- Language: JavaScript
- Homepage:
- Size: 72.3 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# esbuild-plugin-replace-regex
[](https://www.npmjs.com/package/esbuild-plugin-replace-regex)
Simple esbuild plugin for replacing file content while bundling.
## Installation
```console
npm i esbuild-plugin-replace-regex --save-dev
```
## Usage
```js
const replacePlugin = require('esbuild-plugin-replace-regex');
...
plugins: [
replacePlugin({
filter: /myfile/,
patterns: [
['VERSION', 'v7.7.7'],
[/myfunc\((.+?)\)/g, (m, arg) => `replaced(123, ${arg})`],
]
})
]
...
```
## Options
```js
{
filter = /.*/,
loader = "tsx",
encoding = "utf-8",
patterns = []
}
```