aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/webpack.config.js
diff options
context:
space:
mode:
authorSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-01 04:42:40 +0800
committerSteve Klebanoff <steve.klebanoff@gmail.com>2018-12-01 04:42:40 +0800
commitab631060a05fc6344ef6e2de7b0e6a0f0096e8ed (patch)
treef958921057cad63211ee46c86d1f5ee6521b37b9 /packages/instant/webpack.config.js
parente59d47eac82d2db85b301b24aad4c1e41246daa8 (diff)
downloaddexon-sol-tools-ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed.tar
dexon-sol-tools-ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed.tar.gz
dexon-sol-tools-ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed.tar.bz2
dexon-sol-tools-ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed.tar.lz
dexon-sol-tools-ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed.tar.xz
dexon-sol-tools-ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed.tar.zst
dexon-sol-tools-ab631060a05fc6344ef6e2de7b0e6a0f0096e8ed.zip
cdn -> dischargeTarget, and report to heap
Diffstat (limited to 'packages/instant/webpack.config.js')
-rw-r--r--packages/instant/webpack.config.js25
1 files changed, 14 insertions, 11 deletions
diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js
index 020fab506..a6fe0535d 100644
--- a/packages/instant/webpack.config.js
+++ b/packages/instant/webpack.config.js
@@ -6,12 +6,14 @@ const webpack = require('webpack');
// The common js bundle (not this one) is built using tsc.
// The umd bundle (this one) has a different entrypoint.
-const CDNS_THAT_REQUIRE_HEAP = ['production', 'staging', 'dogfood'];
-const getConfigForCdn = cdnName => {
+const DISCHARGE_TARGETS_THAT_REQUIRED_HEAP = ['production', 'staging', 'dogfood'];
+const getConfigForDischargeTarget = dischargeTarget => {
return {
heapAnalyticsIdEnvName:
- cdnName === 'production' ? 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION' : 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT',
- heapAnalyticsIdRequired: CDNS_THAT_REQUIRE_HEAP.includes(cdnName),
+ dischargeTarget === 'production'
+ ? 'INSTANT_HEAP_ANALYTICS_ID_PRODUCTION'
+ : 'INSTANT_HEAP_ANALYTICS_ID_DEVELOPMENT',
+ heapAnalyticsIdRequired: DISCHARGE_TARGETS_THAT_REQUIRED_HEAP.includes(dischargeTarget),
};
};
@@ -19,14 +21,14 @@ const GIT_SHA = childProcess
.execSync('git rev-parse HEAD')
.toString()
.trim();
-const generateConfig = (cdnName, configOptions) => {
+const generateConfig = (dischargeTarget, configOptions) => {
const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd';
const { heapAnalyticsIdEnvName, heapAnalyticsIdRequired } = configOptions;
const heapAnalyticsId = process.env[heapAnalyticsIdEnvName];
if (heapAnalyticsIdRequired && !heapAnalyticsId) {
throw new Error(
- `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${cdnName}`,
+ `Must define heap analytics id in ENV var ${heapAnalyticsIdEnvName} when building for ${dischargeTarget}`,
);
}
@@ -34,12 +36,13 @@ const generateConfig = (cdnName, configOptions) => {
GIT_SHA: JSON.stringify(GIT_SHA),
NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version),
};
- if (cdnName) {
- envVars.INSTANT_CDN = JSON.stringify(cdnName);
+ if (dischargeTarget) {
+ envVars.INSTANT_DISCHARGE_TARGET = JSON.stringify(dischargeTarget);
}
if (heapAnalyticsId) {
envVars.HEAP_ANALYTICS_ID = JSON.stringify(heapAnalyticsId);
}
+ console.log(envVars);
const config = {
entry: {
@@ -91,7 +94,7 @@ const generateConfig = (cdnName, configOptions) => {
};
module.exports = (env, _argv) => {
- const cdnName = env ? env.cdn : undefined;
- const configOptions = getConfigForCdn(cdnName);
- return generateConfig(cdnName, configOptions);
+ const dischargeTarget = env ? env.discharge_target : undefined;
+ const configOptions = getConfigForDischargeTarget(dischargeTarget);
+ return generateConfig(dischargeTarget, configOptions);
};