diff --git a/package.json b/package.json index d1f1ec996..922722e86 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,7 @@ "@types/ua-parser-js": "0.7.39", "@typescript-eslint/eslint-plugin": "5.61.0", "@typescript-eslint/parser": "5.61.0", + "@vitejs/plugin-basic-ssl": "1.1.0", "@vitejs/plugin-react-swc": "3.3.2", "cross-env": "7.0.3", "cypress": "13.1.0", @@ -116,8 +117,7 @@ "run-script-os": "1.1.6", "sass": "1.62.1", "typescript": "5.1.6", - "vite": "4.4.12", - "vite-plugin-mkcert": "1.16.0", + "vite": "4.5.0", "vite-plugin-node-polyfills": "0.9.0", "vite-plugin-svgr": "3.2.0", "vite-tsconfig-paths": "4.2.0" diff --git a/src/appConstants/index.ts b/src/appConstants/index.ts index 50cf0f4b0..ec855600e 100644 --- a/src/appConstants/index.ts +++ b/src/appConstants/index.ts @@ -1,6 +1,6 @@ export * from './apiFields'; -export const BRAND_NAME = process.env.VITE_APP_BRAND_NAME ?? 'MultiversX'; +export const BRAND_NAME = import.meta.env.VITE_APP_BRAND_NAME ?? 'MultiversX'; export const METACHAIN_SHARD_ID = 4294967295; export const MAIN_SHARD_ID = 4294967293; diff --git a/src/components/ErrorElement/ErrorElement.tsx b/src/components/ErrorElement/ErrorElement.tsx index 0c4f44c0f..8e78f7489 100644 --- a/src/components/ErrorElement/ErrorElement.tsx +++ b/src/components/ErrorElement/ErrorElement.tsx @@ -5,7 +5,7 @@ import { faTimes } from 'icons/regular'; export const ErrorElement = () => { const { pathname } = useLocation(); - const explorerVersion = process.env.VITE_APP_CACHE_BUST; + const explorerVersion = import.meta.env.VITE_APP_CACHE_BUST; const error = useRouteError(); console.error(error); diff --git a/src/config/helpers/getInternalLinks.ts b/src/config/helpers/getInternalLinks.ts index 8b226289e..4a6127599 100644 --- a/src/config/helpers/getInternalLinks.ts +++ b/src/config/helpers/getInternalLinks.ts @@ -2,17 +2,20 @@ import { DEFAULT_HOSTNAME } from 'config'; import { NetworkType, NetworkUrlType } from 'types/network.types'; export const getInternalLinks = (networks: NetworkType[]): NetworkUrlType[] => { - if ( - process.env.NODE_ENV === 'production' && - process.env.VITE_APP_SHARE_PREFIX === 'internal-' - ) { + const isInternal = + import.meta.env.NODE_ENV === 'production' && + import.meta.env.VITE_APP_SHARE_PREFIX === 'internal-'; + + if (isInternal) { const internalLinks = networks .filter(({ id, name, isCustom }) => id && name && !isCustom) .map(({ id = '', name = '' }) => { return { id, name, - url: `https://${id}.${process.env.VITE_APP_SHARE_PREFIX}${DEFAULT_HOSTNAME}` + url: `https://${id}.${ + import.meta.env.VITE_APP_SHARE_PREFIX + }${DEFAULT_HOSTNAME}` }; }); diff --git a/src/config/helpers/getInternalNetworks.ts b/src/config/helpers/getInternalNetworks.ts index e68ba05ee..19f06e0a3 100644 --- a/src/config/helpers/getInternalNetworks.ts +++ b/src/config/helpers/getInternalNetworks.ts @@ -1,11 +1,11 @@ import { NetworkAdapterEnum, NetworkType } from 'types'; export const getInternalNetworks = (): NetworkType[] => { - if (process.env.VITE_APP_INTERNAL_NETWORKS) { + const internalNetworks = import.meta.env.VITE_APP_INTERNAL_NETWORKS; + + if (internalNetworks) { try { - const decodedNetworks = atob( - String(process.env.VITE_APP_INTERNAL_NETWORKS) - ); + const decodedNetworks = atob(String(internalNetworks)); const parsedNetworks = JSON.parse(decodedNetworks); if (parsedNetworks && parsedNetworks.length > 0) { diff --git a/src/config/sharedConfig.ts b/src/config/sharedConfig.ts index 738e4c02a..5861abbc2 100644 --- a/src/config/sharedConfig.ts +++ b/src/config/sharedConfig.ts @@ -27,12 +27,12 @@ export { GAS_PRICE }; -export const SHARE_PREFIX = process.env.VITE_APP_SHARE_PREFIX - ? process.env.VITE_APP_SHARE_PREFIX.replace('-', '') - : ''; +const ENV_PREFIX = import.meta.env.VITE_APP_SHARE_PREFIX; + +export const SHARE_PREFIX = ENV_PREFIX ? ENV_PREFIX.replace('-', '') : ''; export const DEFAULT_HOSTNAME = - process.env.VITE_APP_DEFAULT_HOSTNAME ?? 'explorer.multiversx.com'; + import.meta.env.VITE_APP_DEFAULT_HOSTNAME ?? 'explorer.multiversx.com'; export const hasExtraNetworks = true; diff --git a/src/helpers/cookie.ts b/src/helpers/cookie.ts index 5cbefd48b..b1381f878 100644 --- a/src/helpers/cookie.ts +++ b/src/helpers/cookie.ts @@ -3,7 +3,9 @@ import { DEFAULT_HOSTNAME } from 'config/sharedConfig'; type KeyType = typeof CUSTOM_NETWORK_ID; -const domain = `domain=.${process.env.VITE_APP_SHARE_PREFIX}${DEFAULT_HOSTNAME}`; +const domain = `domain=.${ + import.meta.env.VITE_APP_SHARE_PREFIX +}${DEFAULT_HOSTNAME}`; export const cookie = { saveToCookies: ({ diff --git a/src/helpers/downloadFile.ts b/src/helpers/downloadFile.ts index a48ba6491..bbd9b1726 100644 --- a/src/helpers/downloadFile.ts +++ b/src/helpers/downloadFile.ts @@ -20,7 +20,7 @@ export const getFileMetadata = (type: DownloadFileType['fileType']) => { }; export const downloadFile = ({ data, name, fileType }: DownloadFileType) => { - if (data && name && process.env.NODE_ENV !== 'test') { + if (data && name && import.meta.env.NODE_ENV !== 'test') { const type = getFileMetadata(fileType); const blob = new Blob([data], { type }); diff --git a/src/hooks/fetch/useFetchMarkers.ts b/src/hooks/fetch/useFetchMarkers.ts index a115c9c35..3e5a7a770 100644 --- a/src/hooks/fetch/useFetchMarkers.ts +++ b/src/hooks/fetch/useFetchMarkers.ts @@ -17,7 +17,7 @@ const schema = object({ export const useFetchMarkers = () => { const dispatch = useDispatch(); - const markerUrl = process.env.VITE_APP_MARKERS_API_URL; + const markerUrl = import.meta.env.VITE_APP_MARKERS_API_URL; const { getMarkers } = useAdapter(); const { isFetched } = useSelector(markersSelector); diff --git a/src/hooks/useCheckVersion.ts b/src/hooks/useCheckVersion.ts index ca270f7f3..653d717de 100644 --- a/src/hooks/useCheckVersion.ts +++ b/src/hooks/useCheckVersion.ts @@ -15,8 +15,8 @@ export const useCheckVersion = () => { const isMainnetExplorer = window.location.origin === 'https://explorer.multiversx.com'; - const explorerVersion = process.env.VITE_APP_CACHE_BUST; - const explorerVersionUrl = process.env.VITE_APP_VERSION_URL; + const explorerVersion = import.meta.env.VITE_APP_CACHE_BUST; + const explorerVersionUrl = import.meta.env.VITE_APP_VERSION_URL; const withinInterval = moment() .subtract(refreshRate, 'ms') diff --git a/src/hooks/useGetShardText.ts b/src/hooks/useGetShardText.ts index ec49337fc..54c1ba5a1 100644 --- a/src/hooks/useGetShardText.ts +++ b/src/hooks/useGetShardText.ts @@ -38,7 +38,7 @@ export const useGetShardText = () => { return 'All Shards'; } if (Number(shard) === 0 && isSovereign) { - return name ?? process.env.VITE_APP_BRAND_NAME ?? 'Sovereign Chain'; + return name ?? import.meta.env.VITE_APP_BRAND_NAME ?? 'Sovereign Chain'; } return `Shard ${shard}`; }; diff --git a/src/layouts/Layout/components/Footer/Footer.tsx b/src/layouts/Layout/components/Footer/Footer.tsx index 15f965973..09a2e7682 100644 --- a/src/layouts/Layout/components/Footer/Footer.tsx +++ b/src/layouts/Layout/components/Footer/Footer.tsx @@ -6,7 +6,7 @@ import { faHeart } from 'icons/solid'; import { version } from '../../../../../package.json'; export const Footer = () => { - const explorerVersion = process.env.VITE_APP_CACHE_BUST; + const explorerVersion = import.meta.env.VITE_APP_CACHE_BUST; return (