Rollbar Sourcemap Webpack Plugin

3.3.0 · active · verified Wed Apr 22

This Webpack plugin automates the upload of generated sourcemaps to Rollbar after a production build. It addresses the challenge of making minified JavaScript stacktraces useful in Rollbar by ensuring the corresponding sourcemaps are always available. The current stable version is 3.3.0, with ongoing development and maintenance indicated by recent badges and version bumps. Its primary differentiator is deep integration with the Webpack build process, abstracting away the manual `curl` requests or shell scripts typically used for sourcemap uploads, thus reducing setup complexity and potential for error. It requires Webpack 4 or higher since version 3.0.0, streamlining the deployment of sourcemaps for error monitoring.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to configure the plugin in a webpack.config.js to upload sourcemaps for a production build.

const RollbarSourceMapPlugin = require('rollbar-sourcemap-webpack-plugin');
const path = require('path');

const PUBLIC_PATH = 'https://my.cdn.net/assets';

module.exports = {
  mode: 'production',
  devtool: 'hidden-source-map',
  entry: './src/index.js',
  output: {
    path: path.resolve(__dirname, 'dist'),
    publicPath: PUBLIC_PATH,
    filename: 'index-[contenthash].js'
  },
  plugins: [
    new RollbarSourceMapPlugin({
      accessToken: process.env.ROLLBAR_ACCESS_TOKEN ?? 'aaaabbbbccccddddeeeeffff00001111', // Use environment variable in production
      version: process.env.GIT_SHA ?? 'default-version-123',
      publicPath: PUBLIC_PATH,
      includeChunks: ['main'] // Specify chunk name if desired
    })
  ]
};

view raw JSON →