rollup-plugin-search-and-replace
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

rollup-plugin-search-and-replace

A rollup plugin that searches for and replaces text in one or more files. It works synchronously and makes a single replacement or several replacements at once.

The plugin uses a replace-in-file engine for replacements, so you can use all the available options from there.

Install

npm install --save-dev rollup-plugin-search-and-replace
yarn add -D rollup-plugin-search-and-replace

Usage

Create a rollup.config.js configuration file and import the plugin:

import searchAndReplace from 'rollup-plugin-search-and-replace';

export default {
    plugins: [
        searchAndReplace({
            entry: {
                files: 'path/to/file',
                from: /foo/g,
                to: 'bar'
            },
            hook: 'closeBundle'
        })
    ]
};

Options

In addition to the properties and values specified for replacement, users may also specify the options below.

entry

Type: ReplaceInFileConfig
Default: {}

Here you can use all available options from replace-in-file. Note that the current version of the plugin only works in synchronous mode, so you will not be able to use the asynchronous mode of replace-in-file.

hook

Type: String
Default: closeBundle

Rollup hook the plugin should use. Default is closeBundle. A list of all available hooks can be found here.

Package Sidebar

Install

npm i rollup-plugin-search-and-replace

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

10.7 kB

Total Files

10

Last publish

Collaborators

  • vldiliev