Package Exports
- @honeybadger-io/rollup-plugin
Readme
Honeybadger's Rollup Source Map Plugin
Rollup plugin to upload JavaScript sourcemaps to Honeybadger.
Installation
# npm
npm install @honeybadger-io/rollup-plugin --save-dev
# yarn
yarn add @honeybadger-io/rollup-plugin --dev
Configuration
Plugin parameters
These plugin parameters correspond to the Honeybadger Source Map Upload API and Deployments API.
apiKey
(required)- The API key of your Honeybadger project
assetsUrl
(required)- The base URL to production assets (scheme://host/path)
*
wildcards are supported. The plugin combinesassetsUrl
with the generated minified js file name to build the API parameterminified_url
endpoint
(optional — default: "https://api.honeybadger.io/v1/source_maps")- Where to upload your sourcemaps to. Perhaps you have a self hosted sourcemap server you would like to upload your sourcemaps to instead of Honeybadger.
revision
(optional — default: "main")- The deploy revision (i.e. commit hash) that your source map applies to. This could also be a code version. For best results, set it to something unique every time your code changes. See the Honeybadger docs for examples.
silent
(optional — default: false)- If true, silence logging emitted by the plugin.
retries
(optional — default: 3, max: 10)- This package implements fetch retry functionality via the fetch-retry package. Retrying helps fix issues like `ECONNRESET` and `SOCKETTIMEOUT` errors.
rollup.config.js
Set output.sourcemap
to true
or 'hidden'
. Add the honeybadger plugin to the plugins array.
import honeybadgerRollupPlugin from '@honeybadger-io/rollup-plugin'
// See plugin params above
const hbPluginOptions = {
apiKey: 'your_key_here',
assetsUrl: 'https://yoursite.foo'
}
export default {
input: 'src/index.js',
output: {
dir: 'dist',
sourcemap: true // Must be true or 'hidden'
},
plugins: [ honeybadgerRollupPlugin(hbPluginOptions) ],
}
Using Vite: vite.config.js
If you're using Vite, you'll set up vite.config.js
instead of rollup.config.js
.
Set build.sourcemap
to true
or 'hidden'
. Add the honeybadger
plugin to rollupOptions.plugins
.
Note: Be careful not to add it to the top-level vite plugins without additional config, or it will upload sourcemaps on serve
rather than just on build
.
import honeybadgerRollupPlugin from '@honeybadger-io/rollup-plugin'
import { defineConfig } from 'vite'
// See plugin params above
const hbPluginOptions = {
apiKey: 'your_key_here',
assetsUrl: 'https://yoursite.foo'
}
export default defineConfig({
plugins: [], // Not here
build: {
sourcemap: true, // Must be true or 'hidden'
rollupOptions: {
plugins: [ honeybadgerRollupPlugin(hbPluginOptions) ]
}
}
})
Development
- Run
npm install
- Run the tests with
npm test
- Build with
npm run build
See the /examples
folder for projects to test against.
License
This package is MIT licensed. See the MIT-LICENSE file in this folder for details.