rollup-plugin-replace
Replace strings in files while bundling them.
Installation
npm install --save-dev rollup-plugin-replace
Usage
Generally, you need to ensure that rollup-plugin-replace goes before other things (like rollup-plugin-commonjs) in your plugins
array, so that those plugins can apply any optimisations such as dead code removal.
import replace from 'rollup-plugin-replace';
export default {
plugins: [
replace({
ENVIRONMENT: JSON.stringify( 'production' )
})
]
};
Options
{
include: 'config.js',
exclude: 'node_modules/**',
delimiters: [ '<@', '@>' ],
VERSION: '1.0.0',
ENVIRONMENT: JSON.stringify( 'development' ),
__dirname: (id) => `'${path.dirname(id)}'`,
values: {
VERSION: '1.0.0',
ENVIRONMENT: JSON.stringify( 'development' )
}
}
License
MIT