diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-21 05:14:20 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-21 05:14:20 +0800 |
commit | 748e3c0c5358b99f15baf4bf95da027c9b83eb89 (patch) | |
tree | 229dac31fdcf95bfcf94274d3e13ca5c2185de6c | |
parent | 728617fed2fee99b2accdcf6d2ddc9036c9ad266 (diff) | |
download | dexon-0x-contracts-748e3c0c5358b99f15baf4bf95da027c9b83eb89.tar dexon-0x-contracts-748e3c0c5358b99f15baf4bf95da027c9b83eb89.tar.gz dexon-0x-contracts-748e3c0c5358b99f15baf4bf95da027c9b83eb89.tar.bz2 dexon-0x-contracts-748e3c0c5358b99f15baf4bf95da027c9b83eb89.tar.lz dexon-0x-contracts-748e3c0c5358b99f15baf4bf95da027c9b83eb89.tar.xz dexon-0x-contracts-748e3c0c5358b99f15baf4bf95da027c9b83eb89.tar.zst dexon-0x-contracts-748e3c0c5358b99f15baf4bf95da027c9b83eb89.zip |
Force source maps on staging and dogfood
-rw-r--r-- | packages/instant/webpack.config.js | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js index e472824f5..e3ba59eb3 100644 --- a/packages/instant/webpack.config.js +++ b/packages/instant/webpack.config.js @@ -35,12 +35,14 @@ const getHeapAnalyticsId = environmentName => { return undefined; }; +const ROLLBAR_PUBLISH_TOKEN_ENV_NAME = 'INSTANT_ROLLBAR_PUBLISH_TOKEN'; +const ROLLBAR_CLIENT_TOKEN_ENV_NAME = 'INSTANT_ROLLBAR_CLIENT_TOKEN'; const getRollbarPlugin = environmentName => { if (!environmentName) { return undefined; } - const publishToken = process.env.INSTANT_ROLLBAR_PUBLISH_TOKEN; + const publishToken = process.env[ROLLBAR_PUBLISH_TOKEN_ENV_NAME]; if (!publishToken) { return undefined; } @@ -65,6 +67,26 @@ const getRollbarPlugin = environmentName => { return new RollbarSourceMapPlugin(rollbarPluginOptions); }; +const validateRollbar = (environmentName, rollbarPlugin) => { + const requiresRollbar = environmentName === 'dogfood' || environmentName === 'staging'; + + if (!requiresRollbar) { + return; + } + + if (!process.env[ROLLBAR_CLIENT_TOKEN_ENV_NAME]) { + throw new Error(`${ROLLBAR_CLIENT_TOKEN_ENV_NAME} must be set for ${environmentName}`); + } + + if (!rollbarPlugin) { + if (environmentName === 'dogfood' || environmentName === 'staging') { + throw new Error( + `Please set rollbar env var ${ROLLBAR_PUBLISH_TOKEN_ENV_NAME} to a Rollbar project access token with post_server_item permissions to deploy source maps to ${environmentName}`, + ); + } + } +}; + module.exports = (env, argv) => { const environmentName = getEnvironmentName(env, argv); const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd'; @@ -76,11 +98,12 @@ module.exports = (env, argv) => { NPM_PACKAGE_VERSION: JSON.stringify(process.env.npm_package_version), HEAP_ANALYTICS_ID: getHeapAnalyticsId(environmentName), ROLLBAR_ENVIRONMENT: JSON.stringify(environmentName), - ROLLBAR_CLIENT_TOKEN: JSON.stringify(process.env.INSTANT_ROLLBAR_CLIENT_TOKEN), + ROLLBAR_CLIENT_TOKEN: JSON.stringify(process.env[ROLLBAR_CLIENT_TOKEN_ENV_NAME]), ROLLBAR_FORCE_DEVELOPMENT_REPORT: JSON.stringify(process.env.INSTANT_ROLLBAR_FORCE_DEVELOPMENT_REPORT), }, }), ]; + const rollbarPlugin = getRollbarPlugin(environmentName); if (rollbarPlugin) { console.log('Using rollbar plugin'); @@ -88,6 +111,7 @@ module.exports = (env, argv) => { } else { console.log('Not using rollbar plugin'); } + validateRollbar(environmentName, rollbarPlugin); const config = { entry: { |