Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: fixed refreshing loop when starting the frontend dev (#75)

Yunwei Xiao18f441efd4a0
diff --git a/frontend/vite.config.js b/frontend/vite.config.js
deleted file mode 100644
index dd0d205506..0000000000
--- a/frontend/vite.config.js
+++ /dev/null
@@ -1,30 +0,0 @@
-// const path = require("path");
-import vue from "@vitejs/plugin-vue";
-
-module.exports = {
- plugins: [vue()],
- optimizeDeps: {
- allowNodeBuiltins: ["postcss", "bytebase"],
- },
- server: {
- proxy: {
- "/api": {
- target: "http://localhost:8080/api",
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/api/, ""),
- },
- },
- },
- resolve: {
- // alias: {
- // "/@/": path.resolve(__dirname, "./src"),
- // },
- },
-};
-
-// NOTE: the following lines is to solve https://github.com/gitpod-io/gitpod/issues/6719
-// tl;dr : the HMR(hot module replacement) will behave differently when VPN is on, and by manually set its prot to 443 should prevent this issue.
-const IS_RUNNING_GITPOD = process.env["GITPOD_WORKSPACE_ID"] !== null;
-if (IS_RUNNING_GITPOD === true) {
- module.exports.server.hmr = { port: 443 };
-}
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
new file mode 100644
index 0000000000..09caa18292
--- /dev/null
+++ b/frontend/vite.config.ts
@@ -0,0 +1,37 @@
+import { defineConfig } from "vite";
+import vue from "@vitejs/plugin-vue";
+
+const SERVER_PORT = process.env.PORT || 3000;
+const HTTPS_PORT = 443;
+
+export default defineConfig(() => {
+ // NOTE: the following lines is to solve https://github.com/gitpod-io/gitpod/issues/6719
+ // tl;dr : the HMR(hot module replacement) will behave differently when VPN is on, and by manually set its port to 443 should prevent this issue.
+ const IS_RUNNING_GITPOD =
+ process.env["GITPOD_WORKSPACE_ID"] !== null &&
+ process.env["GITPOD_WORKSPACE_ID"] !== undefined;
+ return {
+ plugins: [vue()],
+ optimizeDeps: {
+ allowNodeBuiltins: ["postcss", "bytebase"],
+ },
+ server: {
+ port: SERVER_PORT,
+ proxy: {
+ "/api": {
+ target: "http://localhost:8080/api",
+ changeOrigin: true,
+ rewrite: (path) => path.replace(/^\/api/, ""),
+ },
+ },
+ hmr: {
+ port: IS_RUNNING_GITPOD ? HTTPS_PORT : SERVER_PORT,
+ },
+ },
+ resolve: {
+ // alias: {
+ // "/@/": path.resolve(__dirname, "./src"),
+ // },
+ },
+ };
+});