Skip to content

Commit

Permalink
Fix vite env import
Browse files Browse the repository at this point in the history
  • Loading branch information
JunichiSugiura committed Dec 19, 2024
1 parent d900586 commit c10b46e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions packages/keychain/src/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export function Home() {
typeof window !== "undefined" &&
!window.location.hostname.includes("localhost")
) {
posthog.init(process.env.VITE_POSTHOG_KEY!, {
api_host: process.env.VITE_POSTHOG_HOST,
posthog.init(import.meta.env.VITE_POSTHOG_KEY!, {
api_host: import.meta.env.VITE_POSTHOG_HOST,
person_profiles: "always",
enable_recording_console_log: true,
loaded: (posthog) => {
if (process.env.NODE_ENV === "development") posthog.debug();
if (import.meta.env.DEV) posthog.debug();
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/hooks/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useAnalytics = () => {
};

const log = async (type: string, payload: object) => {
if (process.env.NODE_ENV === "development") {
if (import.meta.env.DEV) {
return console.log(type, payload);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/utils/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default class Controller extends Account {
username,
{
webauthn: {
rpId: process.env.VITE_RP_ID!,
rpId: import.meta.env.VITE_RP_ID!,
credentialId,
publicKey,
},
Expand Down
7 changes: 3 additions & 4 deletions packages/keychain/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import process from "node:process";
import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await";

export default defineConfig({
export default defineConfig(({ mode }) => ({
plugins: [wasm(), topLevelAwait(), react()],
server: {
port: process.env.NODE_ENV === "development" ? 3001 : undefined,
port: mode === "development" ? 3001 : undefined,
},
resolve: {
alias: {
Expand All @@ -16,4 +15,4 @@ export default defineConfig({
},
root: "./",
publicDir: "public",
});
}));

0 comments on commit c10b46e

Please sign in to comment.