diff --git a/client/.env.production b/client/.env.production deleted file mode 100644 index 40f3cd70f..000000000 --- a/client/.env.production +++ /dev/null @@ -1,4 +0,0 @@ -VITE_APP_GLOBAL_REFRESH=UPTIME_APP_GLOBAL_REFRESH -VITE_APP_HOST=UPTIME_APP_HOST -VITE_APP_API_BASE_URL=UPTIME_APP_API_BASE_URL -VITE_APP_DEPLOYMENT_MODE=UPTIME_APP_DEPLOYMENT_MODE diff --git a/client/env.sh b/client/env.sh deleted file mode 100644 index d95f8ee8f..000000000 --- a/client/env.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -for i in $(env | grep UPTIME_APP_) -do - key=$(echo $i | cut -d '=' -f 1) - value=$(echo $i | cut -d '=' -f 2-) - echo $key=$value - find /usr/share/nginx/html -type f \( -name '*.js' -o -name '*.css' \) -exec sed -i "s|${key}|${value}|g" '{}' + -done \ No newline at end of file diff --git a/client/public/env.js b/client/public/env.js new file mode 100644 index 000000000..d78193b88 --- /dev/null +++ b/client/public/env.js @@ -0,0 +1,6 @@ +window.__ENV = { + GLOBAL_REFRESH: "60000", + APP_HOST: "http://localhost:5173", + APP_API_BASE_URL: "http://localhost:52345/api/v1", + APP_DEPLOYMENT_MODE: "self_hosted", +}; diff --git a/client/vite.config.ts b/client/vite.config.ts index 9bac9d0e3..49765bd5a 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -1,4 +1,4 @@ -import { defineConfig } from "vite"; +import { defineConfig, type Plugin } from "vite"; import react from "@vitejs/plugin-react"; import svgr from "vite-plugin-svgr"; import path from "path"; @@ -6,10 +6,22 @@ import { fileURLToPath } from "url"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); +const publicReload = (): Plugin => ({ + name: "public-reload", + configureServer(server) { + // Watch all files under public and trigger a full reload on change + server.watcher.add("public/**"); + const reload = () => server.ws.send({ type: "full-reload" }); + server.watcher.on("add", reload); + server.watcher.on("change", reload); + server.watcher.on("unlink", reload); + }, +}); + export default defineConfig(() => { return { base: "/", - plugins: [svgr(), react()], + plugins: [svgr(), react(), publicReload()], resolve: { alias: { "@": path.resolve(__dirname, "src"),