Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dev/production build #472

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions src/main/index.ts
Original file line number Diff line number Diff line change
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,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));
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
Loading