Skip to content

Commit

Permalink
fix: dev/production build
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjozork committed Aug 21, 2024
1 parent 573c529 commit 15e17c6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/main/SentryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 10 additions & 4 deletions src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { app, BrowserWindow, Menu, shell, ipcMain } from 'electron';
import { app, BrowserWindow, Menu, shell, ipcMain, dialog } from 'electron';
import { NsisUpdater } from 'electron-updater';
import installExtension, { REDUX_DEVTOOLS, REACT_DEVELOPER_TOOLS } from 'electron-devtools-installer';
import * as packageInfo from '../../package.json';
Expand Down Expand Up @@ -122,7 +122,7 @@ function initializeApp() {

mainWindow.center();

if (process.env.NODE_ENV === 'development') {
if (import.meta.env.DEV) {
mainWindow.webContents.openDevTools();
}

Expand All @@ -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', () => {
Expand Down Expand Up @@ -213,7 +213,13 @@ function initializeApp() {
app.on('ready', () => {
createWindow();

if (process.env.NODE_ENV === 'development') {
const extraResourcesPath = import.meta.env.PROD
? path.join(process.resourcesPath, 'extraResources')
: 'extraResources';

void dialog.showMessageBox({ type: 'info', message: extraResourcesPath });

if (import.meta.env.DEV) {
installExtension(REACT_DEVELOPER_TOOLS)
.then((name) => console.log(`Added Extension: ${name}`))
.catch((err) => console.log('An error occurred: ', err));
Expand Down
7 changes: 4 additions & 3 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// <reference types="node" />
// <reference types="react" />
// <reference types="react-dom" />
import 'node';
import 'react';
import 'react-dom';
import 'vite/client';

declare namespace NodeJS {
interface ProcessEnv {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/App/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const NavBar: FC = ({ children }) => {
<div className="flex flex-col gap-y-5">{children}</div>

<div className="mt-auto flex flex-col gap-y-5">
{process.env.NODE_ENV === 'development' && (
{import.meta.env.DEV && (
<NavbarItem to="/debug" className="border-none">
<Wrench className="text-gray-100" size={28} strokeWidth={1} />
</NavbarItem>
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const App = () => {
<div className="flex h-full flex-1 flex-row items-stretch overflow-hidden">
<Logo />

{process.env.NODE_ENV === 'development' && (
{import.meta.env.DEV && (
<div className="my-auto ml-32 flex gap-x-4 text-2xl text-gray-400">
<pre>{packageInfo.version}</pre>
<pre className="text-gray-500">|</pre>
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"allowJs": true,
"module": "commonjs",
"module": "ESNext",
"skipLibCheck": true,
"esModuleInterop": true,
"noImplicitAny": true,
Expand Down

0 comments on commit 15e17c6

Please sign in to comment.