@kingyue/rollup-plugin-modify
TypeScript icon, indicating that this package has built-in type declarations

4.1.0 • Public • Published

version license

🔎 rollup-plugin-modify

Modify rollup output with find / replace dynamically.

Usage

npm i rollup-plugin-modify

Explicit single using find, replace keys

import modify from 'rollup-plugin-modify'

export default {
  plugins: [
    modify({
      find: String | RegExp,
      replace: String | Function
    })
  ]
}

Terse multiple using key, value

import modify from 'rollup-plugin-modify'

export default {
  plugins: [
    modify({
      'find this text': 'replace with this here',
      'process.env.PORT': 5000
    })
  ]
}

find: String|RegExp

Supply a string or RegExp to find what you are looking for

replace: String|Function

Supply a string to directly replace what you've found, or a function to dynamically modify your findings

Example using String for both find and replace

modify({
  find: 'eval',
  replace: 'lava'
})

Example using RegExp for find and a Function for replace

modify({
  find: /svg\((.*?)\)/,
  replace: (match, path) => JSON.stringify(fs.readFileSync(path, 'utf8'))
})

Package Sidebar

Install

npm i @kingyue/rollup-plugin-modify

Weekly Downloads

2

Version

4.1.0

License

WTFPL

Unpacked Size

5.93 kB

Total Files

6

Last publish

Collaborators

  • kingyue