From 04afe3318ca12051e2c75bcaf032c87a08ffe560 Mon Sep 17 00:00:00 2001 From: Benjamin Dupont <4503241+Benjozork@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:47:58 -0400 Subject: [PATCH] fix: dev/production build (#472) * fix: dev/production build * chore: remove debug dialog --- src/main/SentryClient.ts | 5 +++-- src/main/index.ts | 6 +++--- src/react-app-env.d.ts | 7 ++++--- src/renderer/components/App/NavBar.tsx | 2 +- src/renderer/components/App/index.tsx | 2 +- tsconfig.json | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/SentryClient.ts b/src/main/SentryClient.ts index 0751078c..d2349af8 100644 --- a/src/main/SentryClient.ts +++ b/src/main/SentryClient.ts @@ -16,8 +16,9 @@ export class SentryClient { let dsn; try { - const extraResourcesPath = - process.env.NODE_ENV === 'production' ? path.join(process.resourcesPath, 'extraResources') : 'extraResources'; + const extraResourcesPath = import.meta.env.PROD + ? path.join(process.resourcesPath, 'extraResources') + : 'extraResources'; dsn = fs.readFileSync(path.join(extraResourcesPath, '.sentrydsn'), { encoding: 'utf-8' }); } catch (e) { diff --git a/src/main/index.ts b/src/main/index.ts index ca756162..a37f094b 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -122,7 +122,7 @@ function initializeApp() { mainWindow.center(); - if (process.env.NODE_ENV === 'development') { + if (import.meta.env.DEV) { mainWindow.webContents.openDevTools(); } @@ -137,7 +137,7 @@ function initializeApp() { return { action: 'deny' }; }); - if (process.env.NODE_ENV === 'development') { + if (import.meta.env.DEV) { // Open the DevTools. settings.openInEditor(); mainWindow.webContents.once('dom-ready', () => { @@ -213,7 +213,7 @@ function initializeApp() { app.on('ready', () => { createWindow(); - if (process.env.NODE_ENV === 'development') { + if (import.meta.env.DEV) { installExtension(REACT_DEVELOPER_TOOLS) .then((name) => console.log(`Added Extension: ${name}`)) .catch((err) => console.log('An error occurred: ', err)); diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index f4051a5e..a0888d8d 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -1,6 +1,7 @@ -// -// -// +import 'node'; +import 'react'; +import 'react-dom'; +import 'vite/client'; declare namespace NodeJS { interface ProcessEnv { diff --git a/src/renderer/components/App/NavBar.tsx b/src/renderer/components/App/NavBar.tsx index 3e45c8c6..ff658aa6 100644 --- a/src/renderer/components/App/NavBar.tsx +++ b/src/renderer/components/App/NavBar.tsx @@ -17,7 +17,7 @@ export const NavBar: FC = ({ children }) => {
{children}
- {process.env.NODE_ENV === 'development' && ( + {import.meta.env.DEV && ( diff --git a/src/renderer/components/App/index.tsx b/src/renderer/components/App/index.tsx index 0f69920e..3bb23564 100644 --- a/src/renderer/components/App/index.tsx +++ b/src/renderer/components/App/index.tsx @@ -145,7 +145,7 @@ const App = () => {
- {process.env.NODE_ENV === 'development' && ( + {import.meta.env.DEV && (
{packageInfo.version}
|
diff --git a/tsconfig.json b/tsconfig.json index b31ac9ea..c28841db 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "allowJs": true, - "module": "commonjs", + "module": "ESNext", "skipLibCheck": true, "esModuleInterop": true, "noImplicitAny": true,