Skip to content

Simple esbuild plugin for replacing file content while bundling

Notifications You must be signed in to change notification settings

fakundo/esbuild-plugin-replace-regex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 = []
}

About

Simple esbuild plugin for replacing file content while bundling

Topics

Resources

Stars

Watchers

Forks