Sentry plugin
A webpack plugin to upload source maps to Sentry. Forked to support hidden sourcemaps and more configurations.
Installation
Using npm:
$ npm install webpack2-sentry-plugin --save-dev
Using yarn:
$ yarn add webpack2-sentry-plugin --dev
Usage
-
Configure Webpack to use the Plugin:
var SentryPlugin = ;var config =devtool: 'source-map' // Also possible: hidden-source-mapplugins:// Sentry options are requiredorganisation: 'your-organisation-name'project: 'your-project-name'apiKey: processenvSENTRY_API_KEY// Release version name/hash is required{return processenvGIT_SHA}// custom options, like refs to send to sentrybody:refs:repository: 'project-repo'commit: processenvGIT_SHA
Recommended reading for sourcemaps: webpack docs, Sentry docs. If you are using the uglify plugin make sure that it is configured with sourcemaps: true
Options
-
exclude
: RegExp to match for excluded filesvar config =plugins:// Exclude uploading of htmlexclude: /\.html$/... -
include
: RegExp to match for included filesvar config =plugins:// Only upload foo.js & foo.js.mapinclude: /foo.js/... -
filenameTransform
: Function to transform filename before uploading to Sentry. Defaults to prefixing filename with~/
, which is used by Sentry as a host wildcardvar config =plugins:{return 'a-filename-prefix-' + filename} -
release
: Release name to attach source maps to. Can be string or function that returns a string. If a function is passed, it will receive the build hash as an argument
var config = plugins: { return hash }
-
suppressErrors
: Display warnings instead of failing webpack build - useful in case webpack compilation is done during deploy on multiple instances -
baseSentryURL
: URL of Sentry instance. Shouldn't need to set if using sentry.io, but useful if self hosting -
organisation
: Sentry organisation to upload files to -
project
: Sentry project to upload files to -
apiKey
: Sentry api key (Generate one here) -
body
: custom body attributes to send to sentry. See https://docs.sentry.io/learn/releases for details.
Thanks
- Thanks to @MikaAK for creating s3-webpack-plugin, which inspired much of this project
- Thanks to @danharper for creating the original build script implementation
Contributing
Contributions are welcome 😄. To run the tests, please ensure you have the relevant environment variables set up. You can cp .env.example .env
and fill it in with test account credentials. An API key can be created here, assuming you are signed in.
Commands to be aware of
Warning ⚠️: The test suite will create releases & upload files on Sentry. They should be cleaned up afterward, but ensure that you are not overwriting something important!
npm test
: Runs the test suitenpm run build
: Compiles distribution build
Differences to original version
This plugin determines which sourcemap maps to which file and passes this information on to Sentry. That way you can freely rename sourcemaps. Support for devtool: hidden-sourcemap was also added.