Last active
February 16, 2019 15:42
-
-
Save jonoirwinrsa/c556cce342b0efeb409089556e373cde to your computer and use it in GitHub Desktop.
Upload Create React App sourcemaps to Bugsnag - Step 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { upload } = require('bugsnag-sourcemaps'); | |
const appVersion = require('./package.json').version; | |
/** | |
* Uploads the source map with accompanying sources | |
* @param sourceMap - single .map file | |
* @returns {Promise<string>} - upload to Bugsnag | |
*/ | |
function uploadSourceMap(sourceMap) { | |
// Remove .map from the file to get the js filename | |
const minifiedFile = sourceMap.replace('.map', ''); | |
// Remove absolute path to the static assets folder | |
const minifiedFileRelativePath = minifiedFile.split('build/')[1]; | |
return upload({ | |
apiKey: process.env.REACT_APP_BUGSNAG_API_KEY, | |
appVersion: appVersion, | |
overwrite: true, | |
minifiedUrl: `http*://${process.env.REACT_APP_SITE_HOSTNAME}/${minifiedFileRelativePath}`, | |
sourceMap, | |
minifiedFile, | |
projectRoot: __dirname, | |
uploadSources: true, | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment