0.0.2 • Published 2 years ago

esbuild-plugin-replace-regex v0.0.2

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
2 years ago

esbuild-plugin-replace-regex

npm

Simple esbuild plugin for replacing file content while bundling.

Installation

npm i esbuild-plugin-replace-regex --save-dev

Usage

const replacePlugin = require('esbuild-plugin-replace-regex');

...
plugins: [
  replacePlugin({
    filter: /myfile/,
    patterns: [
      ['VERSION', 'v7.7.7'],
      [/myfunc\((.+?)\)/g, (m, arg) => `replaced(123, ${arg})`],
    ]
  })
]
...

Options

{
  filter = /.*/,
  loader = "tsx",
  encoding = "utf-8",
  patterns = []
}