Back to results
armujahid/rollup-plugin-rewrite(opens in a new tab)
Language: JavaScript
- stars
- 1
- watchers
- 1
- forks
- 0
- open issues
- 0
- Last updated
- 12/22/2019
Language: JavaScript
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
npm i rollup-plugin-rewrite
Find and replace using regex
import rewrite from 'rollup-plugin-rewrite' export default { plugins: [ rewrite({ find: RegExp, replace: Function }) ] }
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