loading the right environment variables and getting through main process

This commit is contained in:
talksik
2022-06-03 13:53:23 -07:00
parent 6eb8092864
commit 609d975be2
4 changed files with 39 additions and 6 deletions
+3 -1
View File
@@ -19,7 +19,9 @@
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {},
"packagerConfig": {
"test": "test"
},
"makers": [
{
"name": "@electron-forge/maker-squirrel",
@@ -0,0 +1,25 @@
interface EnvironmentConfig {
API_SERVER_URL: string;
}
// keep private
const getEnvironmentVariables = (): EnvironmentConfig => {
// TODO
if (process.env.NODE_ENV === 'production') {
//
return {
API_SERVER_URL: 'https://api-a4b4we4n4q-wm.a.run.app/',
};
}
if (process.env.NODE_ENV === 'development') {
//
return {
API_SERVER_URL: 'https://localhost:8080',
};
}
throw Error('No environment variables found!');
};
export const environmentVariables: EnvironmentConfig = getEnvironmentVariables();
+10 -5
View File
@@ -1,6 +1,7 @@
import { BrowserWindow, Display, app, ipcMain, screen, systemPreferences } from 'electron';
import Channels, { DEFAULT_APP_PRESET, DimensionChangeRequest } from './electron/constants';
import { environmentVariables } from './electron/config';
import { handleGoogleLogin } from './electron/handleLogin';
import store from './electron/store';
@@ -10,11 +11,15 @@ import store from './electron/store';
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
// eslint-disable-line global-require
app.quit();
}
console.log(`is production ${app.isPackaged}`);
console.log(`variables loaded`, environmentVariables);
if (process.env.NODE_ENV)
if (require('electron-squirrel-startup')) {
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
// eslint-disable-line global-require
app.quit();
}
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
@@ -20,6 +20,7 @@ import NirvanaLogo from '../components/NirvanaLogo';
import { User } from '@nirvana/core/src/models/user.model';
import { blueGrey } from '@mui/material/colors';
import { firebaseAuth } from '../firebase/connect';
import { useMount } from 'react-use';
import { useSnackbar } from 'notistack';
interface IAuthContext {