build: add staging NODE_ENV (#4187)

* refactor: move initializeAnalytics code to top-level

* expect that there's a node env per key

* remove more dev specific stuff

* module.exports

* remove locales

* fix

* service worker update
This commit is contained in:
Vignesh Mohankumar 2022-08-04 12:03:41 -04:00 committed by GitHub
parent 5a9b1e1001
commit bd55b1ccdc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 3 additions and 4 deletions

1
.env

@ -1,3 +1,2 @@
REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
REACT_APP_FORTMATIC_KEY="pk_live_357F77728B8EB880"
REACT_APP_LOCALES="locales"

@ -1,4 +1,4 @@
const isDev = process.env.NODE_ENV !== 'production'
const isDev = process.env.NODE_ENV === 'development'
module.exports = {
styledComponents: {

@ -79,7 +79,7 @@ const plurals: LocalePlural = {
export async function dynamicActivate(locale: SupportedLocale) {
i18n.loadLocaleData(locale, { plurals: () => plurals[locale] })
try {
const catalog = await import(`${process.env.REACT_APP_LOCALES}/${locale}.js`)
const catalog = await import(`locales/${locale}.js`)
// Bundlers will either export it as default or as a named export named default.
i18n.load(locale, catalog.messages || catalog.default.messages)
} catch {}

@ -93,7 +93,7 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
}
export function register(config?: Config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
if (['production', 'staging'].includes(process.env.NODE_ENV) && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href)
if (publicUrl.origin !== window.location.origin) {