bugsnag / webpack-bugsnag-plugins

Webpack plugins for common BugSnag actions.
MIT License
32 stars 29 forks source link
bugsnag platforms webpack-plugin

webpack-bugsnag-plugins

Build status NPM

Webpack plugins for common Bugsnag actions.

Installation

npm install --save-dev webpack-bugsnag-plugins

Plugins

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.

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.

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

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.