diff options
author | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-21 03:39:31 +0800 |
---|---|---|
committer | Steve Klebanoff <steve.klebanoff@gmail.com> | 2018-11-21 03:39:31 +0800 |
commit | d2dd5f93d21404ee5424792a4e29e843140a7fa1 (patch) | |
tree | c27e345fb6489ae5537cbdb1a930fb5ce06af25f /packages/instant/webpack.config.js | |
parent | ac1ffe53df90df9ecf4aca972a5625568f0b2a3a (diff) | |
download | dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.gz dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.bz2 dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.lz dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.xz dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.tar.zst dexon-sol-tools-d2dd5f93d21404ee5424792a4e29e843140a7fa1.zip |
Introduce rollbar plugin
Diffstat (limited to 'packages/instant/webpack.config.js')
-rw-r--r-- | packages/instant/webpack.config.js | 63 |
1 files changed, 52 insertions, 11 deletions
diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js index 161e7d1b0..2375bbd31 100644 --- a/packages/instant/webpack.config.js +++ b/packages/instant/webpack.config.js @@ -1,6 +1,7 @@ const childProcess = require('child_process'); const ip = require('ip'); const path = require('path'); +const RollbarSourceMapPlugin = require('rollbar-sourcemap-webpack-plugin'); const webpack = require('webpack'); // The common js bundle (not this one) is built using tsc. @@ -34,9 +35,59 @@ const getHeapAnalyticsId = environmentName => { return undefined; }; +const getRollbarPlugin = environmentName => { + if (!environmentName) { + return undefined; + } + + const publishToken = process.env.INSTANT_ROLLBAR_PUBLISH_TOKEN; + if (!publishToken) { + return undefined; + } + + let rollbarPublicPath; + if (environmentName === 'dogfood') { + rollbarPublicPath = 'http://0x-instant-dogfood.s3-website-us-east-1.amazonaws.com'; + } else if (environmentName === 'staging') { + rollbarPublicPath = 'http://0x-instant-staging.s3-website-us-east-1.amazonaws.com'; + } + + if (!rollbarPublicPath) { + console.log('No rollbar public path'); + return undefined; + } + + const rollbarPluginOptions = { + accessToken: publishToken, + version: GIT_SHA, + publicPath: rollbarPublicPath, + }; + return new RollbarSourceMapPlugin(rollbarPluginOptions); +}; + module.exports = (env, argv) => { const environmentName = getEnvironmentName(env, argv); const outputPath = process.env.WEBPACK_OUTPUT_PATH || 'umd'; + + let plugins = [ + new webpack.DefinePlugin({ + 'process.env': { + GIT_SHA: JSON.stringify(GIT_SHA), + 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), + }, + }), + ]; + const rollbarPlugin = getRollbarPlugin(environmentName); + if (rollbarPlugin) { + console.log('Using rollbar plugin'); + plugins = plugins.concat(rollbarPlugin); + } else { + console.log('Not using rollbar plugin'); + } + const config = { entry: { instant: './src/index.umd.ts', @@ -47,17 +98,7 @@ module.exports = (env, argv) => { library: 'zeroExInstant', libraryTarget: 'umd', }, - plugins: [ - new webpack.DefinePlugin({ - 'process.env': { - GIT_SHA: JSON.stringify(GIT_SHA), - 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), - }, - }), - ], + plugins, devtool: 'source-map', resolve: { extensions: ['.js', '.json', '.ts', '.tsx'], |