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-rollbarVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic setup of the `vite-plugin-rollbar` within a Vite configuration, enabling sourcemap generation and upload to Rollbar after a production build.
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.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.
Wrap the plugin in a conditional statement to only apply it during production builds: `plugins: [ process.env.NODE_ENV === 'production' && viteRollbar(rollbarConfig) ].filter(Boolean)`.
Change `const viteRollbar = require('vite-plugin-rollbar')` to `import viteRollbar from 'vite-plugin-rollbar'`.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.
Run `npm install vite-plugin-rollbar --save-dev` or `yarn add vite-plugin-rollbar --dev` to ensure the package is correctly installed.