0.0.4 • Published 6 years ago
rollup-plugin-rewrite v0.0.4
🔎 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-rewriteFind 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