Webpack plugins for BugSnag
Webpack plugins for reporting new builds to your dashboard and uploading source maps for deobfuscating stack traces.
Installation
npm install --save-dev webpack-bugsnag-pluginsPlugins
new BugsnagBuildReporterPlugin(build, opts):WebpackPlugin
const { BugsnagBuildReporterPlugin } = require('webpack-bugsnag-plugins')Reports your application's build to BugSnag. It can auto detect source control from .git, .hg and package.json. This plugin hooks into the 'after-emit' event once all output files have been generated by the Webpack compiler. If anything causes the compilation to fail before this step, the build report will not get sent.
builddescribes the build you are reporting to BugsnagapiKey: stringyour Bugsnag API key [required]appVersion: stringthe version of the application you are building [required]releaseStage: string'production','staging'etc. (leave blank if this build can be released to differentreleaseStages)sourceControl: objectan object describing the source control of the build (if not specified, the module will attempt to detect source control information from.git,.hgand the nearestpackage.json)provider: stringcan be one of:'github','github-enterprise','gitlab','gitlab-onpremise','bitbucket','bitbucket-server'repository: stringa URL (git/ssh/https) pointing to the repository, or webpage representing the repositoryrevision: stringthe unique identifier for the commit (e.g. git SHA)
builderName: stringthe name of the person/machine that created this build (defaults to the result of thewhoamicommand)autoAssignRelease: booleanautomatically associate this build with any new error events and sessions that are received for thereleaseStageuntil a subsequent build notification is received. If this is set totrueand noreleaseStageis provided the build will be applied to'production'.metadata: objectan object describing key/value pairs containing any custom build information that provides useful metadata about the build. e.g. build configuration parameters, versions of dependencies, reason for the build etc.
optslogLevel: stringthe minimum severity of log to output ('debug','info','warn','error'), default'warn'logger: objectprovide a different logger object{ debug, info, warn, error }path: stringthe path to search for source control info, defaults toprocess.cwd()endpoint: stringpost the build payload to a URL other than the default (https://build.bugsnag.com)
Usage
const { BugsnagBuildReporterPlugin } = require('webpack-bugsnag-plugins')
module.exports = {
entry: './app.js',
output: {
path: __dirname,
filename: './bundle.js'
},
plugins: [].concat(
// It's a good idea to only run this plugin when you're building a bundle
// that will be released, rather than for every development build
isDistEnv
? new BugsnagBuildReporterPlugin({
apiKey: 'YOUR_API_KEY',
appVersion: '1.2.3'
}, { /* opts */ })
: []
)
}new BugsnagSourceMapUploaderPlugin(opts):WebpackPlugin
const { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins')Upload your application's sourcemap(s) to Bugsnag. When Webpack is done producing output, this plugin detects sourcemaps for any output chunks and uploads them to Bugsnag.
optsprovide options to the sourcemap uploaderapiKey: stringyour Bugsnag API key [required]publicPath: stringthe path to your bundled assets (as the browser will see them). This option must either be provided here, or asoutput.publicPathin your Webpack config.appVersion: stringthe version of the application you are building (defaults to theversionset in your project's package.json file, if one is specified there)codeBundleId: stringthe codeBundleId (e.g. for NativeScript projects)overwrite: booleanwhether you want to overwrite previously uploaded sourcemapsendpoint: stringpost the build payload to a URL other than the default (https://upload.bugsnag.com)ignoredBundleExtensions: string[]a list of bundle file extensions which shouldn't be uploaded (default[ '.css' ])
Usage
const { BugsnagSourceMapUploaderPlugin } = require('webpack-bugsnag-plugins')
module.exports = {
entry: './app.js',
devtool: 'source-map',
output: {
path: __dirname,
filename: './bundle.js',
publicPath: 'https://your-app.xyz/assets/'
},
plugins: [].concat(
// It's a good idea to only run this plugin when you're building a bundle
// that will be released, rather than for every development build
isDistEnv
? new BugsnagSourceMapUploaderPlugin({
apiKey: 'YOUR_API_KEY',
appVersion: '1.2.3'
})
: []
)
}Supported Webpack versions
These plugins have been tested with webpack versions 3, 4 and 5.
Support
- Search open and closed issues issues for similar problems
- Report a bug or request a feature
- Email support@bugsnag.com
Contributing
All contributors are welcome! See our contributing guide.
License
This module is free software released under the MIT License. See LICENSE.txt for details.