0.0.4 • Published 4 years ago

rollup-plugin-rewrite v0.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago