Modify rollup output with find / replace dynamically.
npm i rollup-plugin-modify
Explicit single using find, replace keys
import modify from 'rollup-plugin-modify'
export default {
plugins: [
modify({
find: String | RegExp,
replace: String | Function
})
]
}
Terse multiple using key, value
import modify from 'rollup-plugin-modify'
export default {
plugins: [
modify({
'find this text': 'replace with this here',
'process.env.PORT': 5000
})
]
}
Supply a string or RegExp to find what you are looking for
Supply a string to directly replace what you've found, or a function to dynamically modify your findings
modify({
find: 'eval',
replace: 'lava'
})
modify({
find: /svg\((.*?)\)/,
replace: (match, path) => JSON.stringify(fs.readFileSync(path, 'utf8'))
})