Add infura project id via env variables when bundling instant

This commit is contained in:
Brandon Millman 2019-03-26 14:17:07 -07:00
parent 28c4ca73ab
commit c750368a3e
3 changed files with 35 additions and 19 deletions

View File

@ -2,6 +2,8 @@ INSTANT_ROLLBAR_PUBLISH_TOKEN=
INSTANT_ROLLBAR_CLIENT_TOKEN= INSTANT_ROLLBAR_CLIENT_TOKEN=
INSTANT_HEAP_ANALYTICS_ID_PRODUCTION= INSTANT_HEAP_ANALYTICS_ID_PRODUCTION=
INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT= INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT=
INSTANT_INFURA_PROJECT_ID_PRODUCTION=
INSTANT_INFURA_PROJECT_ID_DEVELOPMENT=
# if you want to report to heap or rollbar when building in development mode, you can use the following: # if you want to report to heap or rollbar when building in development mode, you can use the following:
# INSTANT_HEAP_FORCE_DEVELOPMENT=true # INSTANT_HEAP_FORCE_DEVELOPMENT=true
# INSTANT_ROLLBAR_FORCE_DEVELOPMENT=true # INSTANT_ROLLBAR_FORCE_DEVELOPMENT=true

View File

@ -53,8 +53,8 @@ export const META_MASK_CHROME_STORE_URL =
export const META_MASK_OPERA_STORE_URL = 'https://addons.opera.com/en/extensions/details/metamask/'; export const META_MASK_OPERA_STORE_URL = 'https://addons.opera.com/en/extensions/details/metamask/';
export const META_MASK_SITE_URL = 'https://metamask.io/'; export const META_MASK_SITE_URL = 'https://metamask.io/';
export const ETHEREUM_NODE_URL_BY_NETWORK = { export const ETHEREUM_NODE_URL_BY_NETWORK = {
[Network.Mainnet]: 'https://mainnet.infura.io/', [Network.Mainnet]: `https://mainnet.infura.io/v3/${process.env.INSTANT_INFURA_PROJECT_ID}`,
[Network.Kovan]: 'https://kovan.infura.io/', [Network.Kovan]: `https://kovan.infura.io/v3/${process.env.INSTANT_INFURA_PROJECT_ID}`,
}; };
export const ZERO_EX_SITE_URL = 'https://www.0xproject.com/'; export const ZERO_EX_SITE_URL = 'https://www.0xproject.com/';
export const BLOCK_POLLING_INTERVAL_MS = 10000; // 10s export const BLOCK_POLLING_INTERVAL_MS = 10000; // 10s

View File

@ -89,11 +89,17 @@ const generateConfig = (dischargeTarget, heapConfigOptions, rollbarConfigOptions
}); });
} }
const infuraProjectId =
dischargeTarget === 'production'
? process.env.INSTANT_INFURA_PROJECT_ID_PRODUCTION
: process.env.INSTANT_INFURA_PROJECT_ID_DEVELOPMENT;
const envVars = { const envVars = {
GIT_SHA: JSON.stringify(GIT_SHA), GIT_SHA: JSON.stringify(GIT_SHA),
NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version), NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version),
ROLLBAR_ENABLED: rollbarEnabled, ROLLBAR_ENABLED: rollbarEnabled,
HEAP_ENABLED: heapEnabled HEAP_ENABLED: heapEnabled,
INSTANT_INFURA_PROJECT_ID: JSON.stringify(infuraProjectId),
}; };
if (dischargeTarget) { if (dischargeTarget) {
envVars.INSTANT_DISCHARGE_TARGET = JSON.stringify(dischargeTarget); envVars.INSTANT_DISCHARGE_TARGET = JSON.stringify(dischargeTarget);
@ -141,24 +147,32 @@ const generateConfig = (dischargeTarget, heapConfigOptions, rollbarConfigOptions
}, },
{ {
test: /\.js$/, test: /\.js$/,
use: [{ use: [
loader: 'babel-loader', {
options: { loader: 'babel-loader',
"plugins": ["transform-runtime"], options: {
'presets': [ plugins: ['transform-runtime'],
['env', { presets: [
'targets': { [
"chrome": 41 'env',
}, {
}], targets: {
], chrome: 41,
},
},
],
],
},
}, },
}, { {
loader: 'source-map-loader', loader: 'source-map-loader',
}], },
],
exclude: function(modulePath) { exclude: function(modulePath) {
return /node_modules/.test(modulePath) && return (
/node_modules\/(core-js|lodash|react|websocket)/.test(modulePath); /node_modules/.test(modulePath) &&
/node_modules\/(core-js|lodash|react|websocket)/.test(modulePath)
);
}, },
}, },
], ],