Skip to content

Commit

Permalink
fix: check vite mode
Browse files Browse the repository at this point in the history
  • Loading branch information
itschip committed Nov 6, 2023
1 parent c03d49f commit 85aefae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/phone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"scripts": {
"i18n:missing": "node --experimental-json-modules i18n.missingKeys.js",
"dev:old": "cross-env IS_BROWSER_DEV=1 webpack serve --config config/webpack.dev.js --mode development",
"dev": "cross-env IS_BROWSER_DEV=1 vite",
"dev": "cross-env VITE_REACT_APP_IN_GAME=false vite",
"build": "webpack --config config/webpack.production.js --mode production --progress --color",
"dev:game": "cross-env REACT_APP_IN_GAME=1 BROWSER=none webpack --config config/webpack.dev.js --mode development --watch --progress"
},
Expand Down
3 changes: 2 additions & 1 deletion apps/phone/src/common/hooks/useExternalApps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
__federation_method_unwrapDefault,
// @ts-ignore - This is Vite federation magic
} from '__federation__';
import { EnvMode } from '@utils/config';

const useExternalAppsAction = () => {
const loadScript = async (url: string) => {
Expand All @@ -36,7 +37,7 @@ const useExternalAppsAction = () => {

const generateAppConfig = async (appName: string): Promise<IApp> => {
try {
const IN_GAME = import.meta.env.PROD || import.meta.env.REACT_APP_IN_GAME;
const IN_GAME = import.meta.env.PROD || import.meta.env.MODE === EnvMode.GAME;
const url = IN_GAME
? `https://cfx-nui-${appName}/web/dist/remoteEntry.js`
: 'http://localhost:4173/assets/remoteEntry.js';
Expand Down
6 changes: 6 additions & 0 deletions apps/phone/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ export const fetchConfig = async (): Promise<ResourceConfig> => {

return deepMergeObjects({}, defaultConfig, config);
};

export enum EnvMode {
GAME = 'game',
DEV = 'dev',
PROD = 'production',
}

0 comments on commit 85aefae

Please sign in to comment.