rollup-plugin-rewrite

0.0.4 • Public • Published

version license

🔎 rollup-plugin-rewrite

Modify rollup output with find / replace dynamically. It is similar to rollup-plugin-modify but uses renderChunk hook to transform final processed output for each chunk

Usage

npm i rollup-plugin-rewrite

Find and replace using regex

import rewrite from 'rollup-plugin-rewrite'
 
export default {
  plugins: [
    rewrite({
      find: RegExp,
      replace: Function
    })
  ]
}

Example (replace method argument)

following code will replace importShim(./bla) to importShim(./publicPath/bla)

rewrite({
  find: /importShim\(([^)]*)\)/mg,
  replace: (match) => `importShim("./publicPath/${match[1].substr(3)})`
})

I use this snippet to update paths of dynamic imports during build time

Package Sidebar

Install

npm i rollup-plugin-rewrite

Weekly Downloads

18

Version

0.0.4

License

MIT

Unpacked Size

3.43 kB

Total Files

4

Last publish

Collaborators

  • armujahid