watchtower/web/vite.config.ts

21 lines
479 B
TypeScript
Raw Normal View History

2022-11-15 14:54:00 +01:00
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
2022-11-15 00:06:15 +01:00
const htmlPlugin = (mode: string) => {
const env = loadEnv(mode, ".");
return {
name: "html-transform",
transformIndexHtml(html: string) {
return html.replace(/%(.*?)%/g, function (match, p1) {
2022-11-15 14:54:00 +01:00
return env[String(p1)];
2022-11-15 00:06:15 +01:00
});
},
};
};
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
plugins: [react(), htmlPlugin(mode)]
}));