Replace a string with another string in all code files. Primary needed for the entry-point index.html file.
// vite.config.ts
// eslint-disable-next-line import/no-extraneous-dependencies, node/no-extraneous-import, import/no-unresolved, node/no-missing-import
import replace from "@lpgroup/vite-plugin-replace";
const replaceArr = [
{ src: "http://localhost:8189/harper-0.0.1.umd.js", production: "/harper/harper-0.0.1.umd.js" },
];
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
return {
plugins: [
// ...otherplugins
replace(replaceArr, mode),
],
};
});
{
/**
* array of object with key/value replace
*/
replace: array
/**
* production or development mode, can get this from vite.
* @default 'development'
*/
mode: string
}