Skip to content

Repository files navigation

Vite Plugin Replace

With this plugin text in sourcecode could be replaced before bundling.

Motivation

The initial reason for implementing a new plugin to replace it was that the approach of @rollup/plugin-replace is not flexible enough. So we looked at what JavaScript replace actually offers us.

Declaration of the Replacement (interface):

interfaceReplacement{from: RegExp|string;to: string|Function}
AttributeTypeDescription
fromregexp | string
tostring | string

Installation

npm i -D vite-plugin-replace

Usage

importpackageJsonfrom"./package.json";import{replaceCodePlugin}from"vite-plugin-replace";module.exports=mergeConfig(config,{plugins: [replaceCodePlugin({replacements: [{from: "__CLI_NAME__",to: packageJson.name,},{from: /__CLI_VERSION__/g,to: packageJson.version,},],}),],});

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages