An esbuild plugin for replacing strings in files during bundling, inspired by @rollup/plugin-replace. Current stable version is 1.4.0. Release cadence appears sporadic with occasional bug fixes and feature additions. Key differentiators: provides include/exclude file filtering, configurable delimiters, and supports both flat replacement objects and a `values` option to separate replacements from plugin options. Delimiters default to word boundaries. Requires Node.js and esbuild. Ships TypeScript declarations.
npm install esbuild-plugin-replaceNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates basic usage of esbuild-plugin-replace to replace __version__ and __author__ with JSON-stringified values during a bundle build.
Use JSON.stringify for objects/arrays: replace({ '__key__': JSON.stringify({foo: 'bar'}) })If using `values` with existing flat replace keys, ensure keys are not duplicated between the top-level and values object.
Use the `values` option: replace({ values: { ... } })replace({ '__config__': JSON.stringify({ key: 'value' }) })Ensure replacement values are either strings or functions that return strings, e.g., JSON.stringify(123)