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:
parent
5a9b1e1001
commit
bd55b1ccdc
1
.env
1
.env
@ -1,3 +1,2 @@
|
|||||||
REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
|
REACT_APP_INFURA_KEY="4bf032f2d38a4ed6bb975b80d6340847"
|
||||||
REACT_APP_FORTMATIC_KEY="pk_live_357F77728B8EB880"
|
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 = {
|
module.exports = {
|
||||||
styledComponents: {
|
styledComponents: {
|
||||||
|
@ -79,7 +79,7 @@ const plurals: LocalePlural = {
|
|||||||
export async function dynamicActivate(locale: SupportedLocale) {
|
export async function dynamicActivate(locale: SupportedLocale) {
|
||||||
i18n.loadLocaleData(locale, { plurals: () => plurals[locale] })
|
i18n.loadLocaleData(locale, { plurals: () => plurals[locale] })
|
||||||
try {
|
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.
|
// Bundlers will either export it as default or as a named export named default.
|
||||||
i18n.load(locale, catalog.messages || catalog.default.messages)
|
i18n.load(locale, catalog.messages || catalog.default.messages)
|
||||||
} catch {}
|
} catch {}
|
||||||
|
@ -93,7 +93,7 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function register(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.
|
// The URL constructor is available in all browsers that support SW.
|
||||||
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href)
|
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href)
|
||||||
if (publicUrl.origin !== window.location.origin) {
|
if (publicUrl.origin !== window.location.origin) {
|
||||||
|
Loading…
Reference in New Issue
Block a user