Skip to content

Commit

Permalink
Adds switch in .env, to be able to switch between production and deve…
Browse files Browse the repository at this point in the history
…lopment (#100)

* vite and env.sample

* ENV enum

---------

Co-authored-by: Peter Ott <[email protected]>
  • Loading branch information
ottpeter and Peter Ott authored Nov 11, 2024
1 parent 026c598 commit 0643fe0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ GATEWAY=86d2154575a43f3bf9922d9c52f0a63daca1cf352d57ef2b5027e38bc8d8f272
STAMP=f07a4b8b5a502edbf36cc1a4859b1ea54c0c6890068fb3bb80c681943f1f625d
# just for local view, github actions will set these
PR_TIMESTAMP=2024.10.07
PR_NUMBER=17
PR_NUMBER=17
ENV=dev
10 changes: 9 additions & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import Coordination from "../assets/category-coordination.png";
import AppliedCryptography from "../assets/category-applied-cryptography.png";
import Entertainment from "../assets/category-entertainment.png";

const enum ENV {
DEV = "dev",
PROD = "prod",
}

export enum ROUTES {
APP = "/",
WELCOME1 = "/welcome1",
Expand Down Expand Up @@ -290,7 +295,10 @@ const TEST_ONE_DIRECTION_CATEGORY_NAMES_TO_ID_MAP = new Map([
]);

export const CATEGORY_NAMES_TO_ID_MAP = createBiDirectionaltMap(
PROD_ONE_DIRECTION_CATEGORY_NAMES_TO_ID_MAP
process.env.ENV === ENV.PROD ?
PROD_ONE_DIRECTION_CATEGORY_NAMES_TO_ID_MAP
:
TEST_ONE_DIRECTION_CATEGORY_NAMES_TO_ID_MAP
);

export const CATEGORY_IMAGES_MAP = new Map([
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default defineConfig(({mode}) => {
'process.env.BACKEND_API_URL': JSON.stringify(env.BACKEND_API_URL) ?? JSON.stringify('https://devcon-backend-1074429022647.asia-southeast1.run.app/'),
'process.env.GATEWAY': JSON.stringify(env.GATEWAY) ?? JSON.stringify(''),
'process.versions': JSON.stringify({ node: 'browser-mock' }), // Mocking process.versions.node
'process.env.ENV': JSON.stringify(env.ENV) ?? JSON.stringify('dev'),
},
plugins: [
react(),
Expand Down

0 comments on commit 0643fe0

Please sign in to comment.