一覧へ戻る
armujahid/rollup-plugin-rewrite(新しいタブで開きます)
主要言語: JavaScript
- star 数
- 1
- watcher 数
- 1
- fork 数
- 0
- issue 数
- 0
- 最終更新
- 2019/12/22
主要言語: 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