• Version 5.0.5
  • Published
  • 25.9 kB
  • 2 dependencies
  • MIT license


npm i @rollup/plugin-replace
yarn add @rollup/plugin-replace
pnpm add @rollup/plugin-replace


Replace strings in files while bundling



function replace

replace: (options?: RollupReplaceOptions) => Plugin;
  • Replace strings in files while bundling them.


interface RollupReplaceOptions

interface RollupReplaceOptions {}

    property delimiters

    delimiters?: [string, string];
    • To replace every occurrence of <@foo@> instead of every occurrence of foo, supply delimiters

    property exclude

    exclude?: FilterPattern;
    • Files that should be excluded, if include is otherwise too permissive.

    property include

    include?: FilterPattern;
    • A picomatch pattern, or array of patterns, of files that should be processed by this plugin (if omitted, all files are included by default)

    property preventAssignment

    preventAssignment?: boolean;
    • Prevents replacing strings where they are followed by a single equals sign.

    property sourceMap

    sourceMap?: boolean;
    • If false, skips source map generation. This will improve performance. true

    property values

    values?: { [str: string]: Replacement };
    • You can separate values to replace from other options.

    index signature

    [str: string]:
    | Replacement
    | RollupReplaceOptions['include']
    | RollupReplaceOptions['values']
    | RollupReplaceOptions['preventAssignment'];
    • All other options are treated as string: replacement replacers, or string: (id) => replacement functions.

    Type Aliases

    type Replacement

    type Replacement = string | ((id: string) => string);

      Package Files (1)

      Dependencies (2)

      Dev Dependencies (6)

      Peer Dependencies (1)


      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@rollup/plugin-replace.

      • Markdown
      • HTML
        <a href="https://www.jsdocs.io/package/@rollup/plugin-replace"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>