Skip to content

Commit

Permalink
refactor(frontend): replace __DEV__ env with __PROD__
Browse files Browse the repository at this point in the history
  • Loading branch information
guerrap committed Aug 2, 2023
1 parent 796e00c commit 9fc3cc3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/frontend/craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ module.exports = {
shared,
}),
new webpack.DefinePlugin({
__DEV__: !production,
__PROD__: production,
__LIBRARY_MODE__: JSON.stringify(false),
__STAGING_MODE__: JSON.stringify(
process.env.STAGING === "true"
process.env.STAGING === "true",
),
__INFURA_PROJECT_ID__: getEnv("INFURA_PROJECT_ID", true),
__WALLETCONNECT_PROJECT_ID__: getEnv(
"WALLETCONNECT_PROJECT_ID",
production
production,
),
__FATHOM_SITE_ID__: getEnv("FATHOM_SITE_ID", production),
}),
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
})
}),
);
if (config.ignoreWarnings)
config.ignoreWarnings.push(/Failed to parse source map/);
Expand All @@ -56,7 +56,7 @@ module.exports = {
new WorkboxWebpackPlugin.InjectManifest({
swSrc: join(__dirname, "/src/sw.ts"),
exclude: [/.+/],
})
}),
);
return config;
},
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default [
values: {
__LIBRARY_MODE__: JSON.stringify(true),
__STAGING_MODE__: JSON.stringify(false),
__DEV__: JSON.stringify(false),
__PROD__: JSON.stringify(true),
__INFURA_PROJECT_ID__: getEnv("INFURA_PROJECT_ID", true),
__WALLETCONNECT_PROJECT_ID__: JSON.stringify(""),
__FATHOM_SITE_ID__: JSON.stringify(""),
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ if (!__LIBRARY_MODE__) {
</StrictMode>,
);

if (!__DEV__ && "serviceWorker" in navigator) {
if (__PROD__ && "serviceWorker" in navigator) {
navigator.serviceWorker
.register("./sw.js")
.then(() => {
Expand Down
4 changes: 3 additions & 1 deletion packages/frontend/src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export const DEFAULT_CHAIN: Chain = Object.values(ENABLED_CHAINS).filter(
(chain) => chain.enabled,
)[0];

export const CARROT_DOMAIN = __DEV__ ? "carrot-kpi.dev" : "carrot-kpi.io";
export const CARROT_DOMAIN = __PROD__
? "carrot-kpi.community"
: "carrot-kpi.dev";

export interface NavbarLink {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { resources } from "./i18n/resources";
import { CARROT_KPI_FRONTEND_I18N_NAMESPACE } from "./constants";

declare global {
const __DEV__: boolean;
const __PROD__: boolean;
const __LIBRARY_MODE__: boolean;
const __STAGING_MODE__: boolean;
const __INFURA_PROJECT_ID__: string;
Expand Down

0 comments on commit 9fc3cc3

Please sign in to comment.