Code for leaning, based on @rollup/plugin-replace
.
Both support for rollup and vite.
- Install:
pnpm add @gyhyfj/rollup-plugin-replace -D
- Usage:
plugins: [
replacePlugin({
// [RegExp|string, string][]
replace: [
['book', 'cat'],
[/!((?<=(\<|\<\/))template(?=\>))/i, 'cat'],
],
// [RegExp|string]
include: ['**/*.(vue|tsx|jsx|ts|js)'],
exclude: ['node_modules/**'],
}),
],
Different from @rollup/plugin-replace
, *.ext
will match *.ext
files at root path of project, which @rollup/plugin-replace
won't.