Vite Plugin Rollbar Sourcemap

raw JSON →
0.0.12 verified Mon Apr 27 auth: no javascript

A Vite plugin that automatically uploads sourcemaps to Rollbar after the build process. Version 0.0.12, expected to release with new features as needed. Key differentiators: TypeScript support, test coverage, and compatibility with Vite 5+ (requiring Vite 8 in peer deps). Inspired by clinggroup's vite-plugin-rollbar, this plugin provides clearer configuration with options like ignoreUploadErrors and silent. It is actively maintained and supports the latest Vite versions.

error TypeError: viteRollbar is not a function
cause Using named import { viteRollbar } instead of default import.
fix
Change to: import viteRollbar from 'vite-plugin-rollbar-sourcemap';
error Cannot find module 'vite'
cause Missing Vite peer dependency.
fix
Install Vite: npm install -D vite@^8.0.0
error Property 'accessToken' is required in type 'RollbarConfig'
cause Missing accessToken in configuration object.
fix
Add accessToken with a valid Rollbar post_server_item token.
breaking Requires Vite 8.0.0 or higher; older Vite versions will fail silently.
fix Upgrade Vite to ^8.0.0
gotcha The accessToken must be a Rollbar post_server_item token, not a client-side token.
fix Generate a post_server_item token from Rollbar project settings.
gotcha Setting ignoreUploadErrors to true suppresses upload failures; plugin may appear to succeed even if upload fails.
fix Set to false and monitor console errors during CI builds.
npm install vite-plugin-rollbar-sourcemap
yarn add vite-plugin-rollbar-sourcemap
pnpm add vite-plugin-rollbar-sourcemap

Demonstrates basic usage of viteRollbar plugin with Vite configuration, including required options and build sourcemap setting.

// vite.config.ts
import { defineConfig } from 'vite';
import viteRollbar from 'vite-plugin-rollbar-sourcemap';

export default defineConfig({
  plugins: [
    viteRollbar({
      accessToken: process.env.ROLLBAR_ACCESS_TOKEN ?? '',
      version: process.env.SOURCE_VERSION ?? '1.0.0',
      baseUrl: 'https://example.com',
      ignoreUploadErrors: true,
      silent: false
    })
  ],
  build: {
    sourcemap: true
  }
});