vite-plugin-sentry-cli v1.0.2
A plugin for intergrating Sentry to Vite ⚡️
It can upload sourcemap files to Sentry during compiling, so that when debugging issues in Sentry, you can reveal the source code.
It's designed for Vite, if you need to use it in Webpack, please see I haven't finished yet
It's based on @sentry/cli, and inspired by vite-plugin-sentry!
Usage
Install
# npm i -D vite-plugin-sentry-cli
yarn add -D vite-plugin-sentry-cliConfig
It should be configed in the vite.config.ts(or something else you named it in your project).
import { defineConfig } from 'vite';
import { vitePluginSentryCli } from 'vite-plugin-sentry-cli'
export default defineConfig({
plugins: [
//...
// the minimun required config
vitePluginSentryCli({
url: '<your_sentry_url>',
org: '<your_sentry_orgination>',
project: '<your_sentry_project>',
authToken: '<your_sentry_auth_token>'
}),
//...
]
})Default behaviour
clean: trueAfter sourcemap is uploaded, it will delete local
*.js.mapfiles by default, to avoid publish these sourcemap to the production during your following steps.If you want to keep them, set it to
false.
delete: trueBefore upload sourcemap, it will delete all previous sourcemap files in the same
releaseby default, it's just better for your server storage and would be cleaner in a release(just in my point).If you want to keep them in your Senrtry, set it to
false.
Q & A
What's
release?When no
releaseis configged, it will generate areleasebySentryCli.releases.proposeVersion()(the project should be agitrepository in this situation), an auto-generatedreleaseis the lastest commit hash.You can also use the
releasein your source code withimport.meta.env.SENTRY_RELEASE(It's automaticly injected). When you configged your ownrelease, this variable will be the value as you configged.For
tssupport, you can add this config to yourtsconfig.json{ "compilerOptions": { "types": ["vite-plugin-sentry-cli/client"] } }What's
authTokenand how can I get one?authTokenis required forsentry-clito get access to yourSentryapplication, it will be used to upload sourcemap and publish new release in your name.Visit your auth token user setting page(like: https://<your_sentry_url>/settings/account/api/auth-tokens/), or following these steps: Login in Sentry -> Click your avatar to navigate to
Account Details-> SelectAuth Tokensmenu -> Use an exsited auth token or create a new one.This auth token should include
project:read/project:releases/org:readscopes at least, that should be already included by default:)More configs?
You might want to check more configs or details here: Configuration and Authentication