Skip to content

Commit 2dcbc04

Browse files
committed
feat: separate env dependent stuff
1 parent 87eb1ba commit 2dcbc04

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

ui/src/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { z } from "zod";
22
import { createZodFetcher } from "zod-fetch";
33

4-
const BASE_URL = "http://localhost:3030/api";
4+
const BASE_URL = import.meta.env.PROD ? "/api" : "http://localhost:3030/api";
55

66
const overview = z.object({
77
file_name: z.string(),

ui/src/main.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import "./index.css";
2+
3+
import React from "react";
24
import { StrictMode } from "react";
35
import ReactDOM from "react-dom/client";
4-
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
56
import { RouterProvider, createRouter } from "@tanstack/react-router";
67
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
78

@@ -18,6 +19,14 @@ declare module "@tanstack/react-router" {
1819
}
1920
}
2021

22+
const ReactQueryDevtools = import.meta.env.PROD
23+
? () => null // Render nothing in production
24+
: React.lazy(() =>
25+
import("@tanstack/react-query-devtools").then((res) => ({
26+
default: res.ReactQueryDevtools,
27+
})),
28+
);
29+
2130
const queryClient = new QueryClient();
2231

2332
// Render the app

ui/src/routes/__root.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
import React from "react";
12
import { Menu, Database } from "lucide-react";
23
import { createRootRoute, Link, Outlet } from "@tanstack/react-router";
3-
import { TanStackRouterDevtools } from "@tanstack/router-devtools";
44

55
import { Button } from "@/components/ui/button";
66
import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet";
77

8+
const TanStackRouterDevtools = import.meta.env.PROD
9+
? () => null // Render nothing in production
10+
: React.lazy(() =>
11+
import("@tanstack/router-devtools").then((res) => ({
12+
default: res.TanStackRouterDevtools,
13+
})),
14+
);
15+
816
export const Route = createRootRoute({
917
component: Root,
1018
});

0 commit comments

Comments
 (0)