Skip to content

Commit

Permalink
use module export for local server global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
interim17 committed Jan 22, 2025
1 parent f5cc197 commit 116050a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions examples/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
declare global {
const SIMULARIUM_USE_LOCAL_BACKEND: boolean;
}

export {};
8 changes: 2 additions & 6 deletions examples/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React from "react";
import { createRoot } from "react-dom/client";

import Viewer from './Viewer';
import Viewer from "./Viewer";

const container: HTMLElement | null = document.getElementById("root");

const root = createRoot(container!);
root.render(
<Viewer
localBackendServer={false /*SIMULARIUM_USE_LOCAL_BACKEND*/}
/>
);
root.render(<Viewer localBackendServer={SIMULARIUM_USE_LOCAL_BACKEND} />);
4 changes: 3 additions & 1 deletion examples/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import react from "@vitejs/plugin-react";
export default {
plugins: [react()],
define: {
SIMULARIUM_USE_LOCAL_BACKEND: "false",
SIMULARIUM_USE_LOCAL_BACKEND: Boolean(
process.env.npm_config_localserver || false
),
},
server: {
open: "examples/src/index.html",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "./tsconfig.base",
"include": ["src/**/*", "vitest.config.ts"],
"include": ["src/**/*", "examples/src/**/*", "vitest.config.ts"],
"exclude": ["src/visGeometry/workers/**/*"],
"compilerOptions": {"types": ["vitest/globals"]}
}

0 comments on commit 116050a

Please sign in to comment.