Registry / devops / vite-plugin-rollbar

vite-plugin-rollbar

JSON →
library0.0.14jsnpmunverified

This Vite plugin, `vite-plugin-rollbar` (current stable version 0.0.14), simplifies the process of uploading sourcemaps generated by a Vite build to Rollbar. It integrates directly into the Vite configuration, abstracting away the manual interactions with the Rollbar API for sourcemap management. The plugin is designed to work seamlessly within modern JavaScript ecosystems that leverage Vite for fast development and optimized production builds, ensuring that critical error tracking and debugging capabilities are maintained in production environments. While a specific release cadence isn't defined, as a Vite plugin, it typically updates to maintain compatibility with new Vite major versions and addresses bug fixes or feature requests. Its key differentiator is providing a straightforward, opinionated solution for Rollbar sourcemap integration specifically tailored for Vite projects, reducing configuration overhead compared to generic sourcemap upload tools. Another community-driven plugin `vite-plugin-rollbar-sourcemap` by madogiwa0124 exists which aims to support the latest Vite with TypeScript and improved code quality.

npm install vite-plugin-rollbar
INSTALL
IMPORT
SIG · VITE-PLUGIN-ROLLBA
V
vite-plugin-rollbar
devopsjavascriptv0.0.14
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

viteRollbar
import viteRollbar from 'vite-plugin-rollbar'
const viteRollbar = require('vite-plugin-rollbar')
Vite configurations are typically ESM, thus `import` syntax is expected. Using `require` will likely lead to an `ERR_REQUIRE_ESM` error.
defineConfig
import { defineConfig } from 'vite'
const defineConfig = require('vite')
Though not directly from `vite-plugin-rollbar`, `defineConfig` is crucial for Vite configurations and follows ESM import patterns.

Demonstrates basic setup of the `vite-plugin-rollbar` within a Vite configuration, enabling sourcemap generation and upload to Rollbar after a production build.

import { defineConfig } from 'vite'; import viteRollbar from 'vite-plugin-rollbar'; export default defineConfig({ plugins: [ viteRollbar({ accessToken: process.env.ROLLBAR_ACCESS_TOKEN ?? 'YOUR_ROLLBAR_ACCESS_TOKEN', version: process.env.APP_VERSION ?? '1.0.0', baseUrl: process.env.ROLLBAR_BASE_URL ?? 'https://yourwebsite.com', // `ignoreUploadErrors` can be useful in CI/CD to prevent build failures ignoreUploadErrors: true, silent: true, // Suppress console output from the plugin // Additional Rollbar config options can be added here }) ], build: { sourcemap: true, // Required: tells Vite to create source maps // Recommended for production builds to ensure unique source map names rollupOptions: { output: { entryFileNames: `[name].[hash].js`, chunkFileNames: `[name].[hash].js`, assetFileNames: `[name].[hash].[ext]` } } } });
Debug
Known issues
gotchaSourcemap generation must be explicitly enabled in your Vite build configuration for this plugin to function. If `build.sourcemap` is not set to `true` or `'hidden'`, no sourcemaps will be generated or uploaded.
fix
Ensure `build: { sourcemap: true }` is present in your `vite.config.ts` or `vite.config.js` file. Consider using `'hidden'` to prevent sourcemaps from being exposed publicly but still allowing upload.
affects: >=0.0.1
gotchaIncorrect Rollbar configuration, particularly `accessToken` or `baseUrl`, will lead to failed sourcemap uploads. The plugin might silently fail if `ignoreUploadErrors` is set to `true`.
fix
Double-check your `accessToken` and `baseUrl` against your Rollbar project settings. For sensitive tokens, use environment variables (`process.env.ROLLBAR_ACCESS_TOKEN`) and ensure they are correctly injected into your build environment. Temporarily set `ignoreUploadErrors: false` and `silent: false` to see detailed upload errors during development or CI.
affects: >=0.0.1
gotchaThe plugin will execute during every build, including development builds, if not conditionally applied. Uploading sourcemaps during development is usually unnecessary and can slow down the build process.
fix
Wrap the plugin in a conditional statement to only apply it during production builds: `plugins: [ process.env.NODE_ENV === 'production' && viteRollbar(rollbarConfig) ].filter(Boolean)`.
affects: >=0.0.1
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported
Attempting to use `require()` to import `vite-plugin-rollbar` in a Vite configuration file, which typically runs in an ESM context.
fix
Change `const viteRollbar = require('vite-plugin-rollbar')` to `import viteRollbar from 'vite-plugin-rollbar'`.
Sourcemaps not found or not uploaded to Rollbar after build.
Sourcemap generation is not enabled in Vite's build configuration or an error occurred during upload (e.g., incorrect API keys).
fix
Verify `build.sourcemap: true` in your `vite.config.ts`. Check Rollbar configuration (`accessToken`, `baseUrl`) and ensure `ignoreUploadErrors: false` for debugging upload issues. Ensure environment variables are correctly passed during the build process.
Failed to resolve 'vite-plugin-rollbar'
The package is not installed or incorrectly listed in `devDependencies`.
fix
Run `npm install vite-plugin-rollbar --save-dev` or `yarn add vite-plugin-rollbar --dev` to ensure the package is correctly installed.
Upgrade
Version history
0.0.14latest on npm
Audit
Dependencies
viterequiredPeer dependency; essential for the plugin to function within a Vite project.
Agent activity
35 hits · last 30 days
node
32
OpenAI (training)
1
Resources
vite-plugin-rollbar — npm install vite-plugin-rollbar · libregistry