{"id":13484949,"url":"https://github.com/ikenfin/vite-plugin-sentry","last_synced_at":"2025-05-15T16:04:09.847Z","repository":{"id":37006606,"uuid":"343324119","full_name":"ikenfin/vite-plugin-sentry","owner":"ikenfin","description":"Vite plugin acting as an interface to SentryCLI","archived":false,"fork":false,"pushed_at":"2025-03-21T12:32:09.000Z","size":1095,"stargazers_count":165,"open_issues_count":9,"forks_count":16,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T21:12:45.925Z","etag":null,"topics":["sentry","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ikenfin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-01T07:16:25.000Z","updated_at":"2025-03-21T01:54:32.000Z","dependencies_parsed_at":"2024-10-02T19:13:43.625Z","dependency_job_id":"003bf252-0f1a-4267-adff-61179aee8110","html_url":"https://github.com/ikenfin/vite-plugin-sentry","commit_stats":{"total_commits":199,"total_committers":8,"mean_commits":24.875,"dds":"0.46733668341708545","last_synced_commit":"1343fce599d79701d75ac3a9525c49c104bce9ce"},"previous_names":[],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikenfin%2Fvite-plugin-sentry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikenfin%2Fvite-plugin-sentry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikenfin%2Fvite-plugin-sentry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ikenfin%2Fvite-plugin-sentry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ikenfin","download_url":"https://codeload.github.com/ikenfin/vite-plugin-sentry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480430,"owners_count":21110937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["sentry","typescript"],"created_at":"2024-07-31T17:01:39.951Z","updated_at":"2025-04-11T21:12:54.409Z","avatar_url":"https://github.com/ikenfin.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Plugin for Vite ⚡️ to create releases and upload sourcemaps to Sentry\n\n![Version](https://img.shields.io/npm/v/vite-plugin-sentry)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](#)[![codecov](https://codecov.io/gh/ikenfin/vite-plugin-sentry/branch/master/graph/badge.svg?token=RAM0TAVIIQ)](https://codecov.io/gh/ikenfin/vite-plugin-sentry)\n\n\u003e This plugin hooks into the Vite build step, to create a new release and upload source maps. It does not instrument error reporting in your app.\n\nIt's a port of official [Sentry webpack plugin](https://github.com/getsentry/sentry-webpack-plugin) for Vite.\n\nIt's fully written on Typescript and there is some differences in configuration, described below, but we mostly follow [@sentry/cli](https://github.com/getsentry/sentry-cli) types.\n\n## Install\n\n```sh\nyarn add -D vite-plugin-sentry\n```\n\n## Configuration\n\nIf you using Typescript - you can use **ViteSentryPluginOptions** type for better configuration experience with autocomplete.\n\nExample config:\n\n```typescript\n// vite.config.ts\n// other declarations\nimport type { ViteSentryPluginOptions } from 'vite-plugin-sentry'\nimport viteSentry from 'vite-plugin-sentry'\n\n/*\n  Configure sentry plugin\n*/\nconst sentryConfig: ViteSentryPluginOptions = {\n  url: 'https://sentry.io',\n  authToken: '\u003cSECRET_TOKEN_HERE\u003e',\n  org: 'my_org',\n  project: 'my_project',\n  release: '1.0',\n  // legacyErrorHandlingMode: true, \u003c- warn about sentry errors instead of fail\n  // cleanSourcemapsAfterUpload: true, \u003c- delete generated sourcemap files after complete\n  deploy: {\n    env: 'production'\n  },\n  setCommits: {\n    auto: true\n  },\n  sourceMaps: {\n    include: ['./dist/assets'],\n    ignore: ['node_modules'],\n    urlPrefix: '~/assets'\n  }\n}\n\nexport default defineConfig({\n  // other options\n  plugins: [ viteSentry(sentryConfig) ],\n  build: {\n    // required: tells vite to create source maps\n    sourcemap: true,\n  }\n})\n```\n\n#### Possible breaking change!\n\nFrom version `1.2.0` we have changed default error handling. Now if Sentry report error while uploading sourcemaps - we crash whole build process instead of just print warning. This was done to prevent calling next to `\u0026\u0026` operator on uploading error.\n\nYou can enable legacy mode using `legacyErrorHandlingMode: true` in plugin config.\n\n## Wiki\n\nCheck project [wiki on github](https://github.com/ikenfin/vite-plugin-sentry/wiki) to get more information.\n\n## Share config with Sentry client library\n\nTo correctly work with Sentry, you need to add a **release** to your project. Same about **dist** option: your uploaded sourcemaps and client sentry initialization must have same release/dist to make sentry correct recognize and bind sourcemaps to logged errors.\n\nYou can expose release and dist options used by vite-plugin-sentry into your application using Vite feature known as virtual module.\n\nTo do so, you need to add several lines:\n\n```javascript\n// import virtual module\n// i would recommend doing it at entry point script (e.g. main.js)\nimport 'virtual:vite-plugin-sentry/sentry-config'\n\n// now you can use this variable like so\nconst dist = import.meta.env.VITE_PLUGIN_SENTRY_CONFIG.dist\nconst release = import.meta.env.VITE_PLUGIN_SENTRY_CONFIG.release\n\n// use it in sentry init\nSentry.init({\n  // other sentry options\n  dist,\n  release\n})\n\n// also, these settings exposed to globalThis object\n// so you can get them from window object:\nconst dist = window.VITE_PLUGIN_SENTRY_CONFIG.dist\nconst release = window.VITE_PLUGIN_SENTRY_CONFIG.release\n```\n\n## TypeScript\n\nTo get type information for the virtual module or import meta env, you can add `vite-plugin-sentry/client` to your `types` array in tsconfig.json.\n\n```javascript\n{\n  \"types\": [\n    \"vite-plugin-sentry/client\"\n  ]\n}\n```\n\nAlso you can use `reference` in your typescript code like below:\n\n```javascript\n///\u003creference types=\"vite-plugin-sentry/client\"/\u003e\n```\n\n## Common how to:\n\n#### Delete generated source maps after upload (#1)\n\n**UPD:** From version 1.2.1 you can use new configuration option `cleanSourcemapsAfterUpload` to clean sourcemap files.\n\nWhile i recommend to use CI, you can also use tools like rimraf in your npm scripts to drop any unnecessary files after build was complete:\n\n```javascript\n// package.json\n{\n  \"scripts\": {\n    // delete all js map files when built\n    \"build\": \"vite build \u0026\u0026 rimraf dist/**/*.js.map\"\n  }\n}\n```\n\n#### Cannot install on Windows\n\nThis plugin relies on @sentry/cli tool, which requires VCRedist to be installed. Please check [#8](https://github.com/ikenfin/vite-plugin-sentry/issues/8) for details.\n\n## List of available options\n\nHere are the list of all plugin options:\n\n**Legend:**\n\n❌ - NOT required\n\n⚠️ - NOT required in plugin config, but MUST be set (for example, using [.sentryclirc](https://docs.sentry.io/product/cli/configuration/#configuration-file) file)\n\n✅ - Required\n\n| Option                     | Type                             | Required | Default value        | Description                                                                                                                                                                                                                                           |\n| -------------------------- | -------------------------------- | -------- | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| legacyErrorHandlingMode    | boolean                          | ❌       | false                | When `true` - all sentry uploading errors will be printed as warnings, build process will not be failed, vite will return exit code 0                                                                                                               |\n| cleanSourcemapsAfterUpload | boolean                          | ❌       | false                | Delete generated sourcemap files after complete                                                                                                                                                                                                       |\n| debug                      | boolean                          | ❌       | false                | Show debug messages during run                                                                                                                                                                                                                        |\n| skipEnvironmentCheck       | boolean                          | ❌       | false                | By default plugin will be enabled only for production builds. Set this option to `true` to skip environment checks                                                                                                                                  |\n| dryRun                     | boolean                          | ❌       | false                | Run sentry in dry mode - will only prints all steps                                                                                                                                                                                                   |\n| url                        | string                           | ❌       | 'https://sentry.io/' | The base URL of your Sentry instance.                                                                                                                                                                                                                 |\n| authToken                  | string                           | ⚠️     | ''                   | The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/settings/account/api/auth-tokens/. Required scopes:`project:releases` (and `org:read` if `setCommits` option is used).                |\n| org                        | string                           | ⚠️     | ''                   | The slug of the Sentry organization associated with the app.                                                                                                                                                                                          |\n| project                    | string                           | ⚠️     | ''                   | The slug of the Sentry project associated with the app.                                                                                                                                                                                               |\n| vcsRemote                  | string                           | ❌       | 'origin'             | The name of the remote in the version control system.                                                                                                                                                                                                 |\n| configFile                 | string                           | ❌       | ''                   | Path to sentry cli config file, as described in https://docs.sentry.io/product/cli/configuration/#configuration-file. By default, the config file is looked for upwards from the current path, and defaults from `~/.sentryclirc` are always loaded |\n| release                    | string                           | ❌       |                      | Unique name for release. Defaults to sentry-cli releases propose version (requires access to GIT and root directory to be repo)                                                                                                                       |\n| finalize                   | boolean                          | ❌       | false                | Determines whether processed release should be automatically finalized after artifacts upload                                                                                                                                                         |\n| silent                     | boolean                          | ❌       | false                | If true, all sentry-cli logs are suppressed                                                                                                                                                                                                           |\n| deploy                     | SentryCliNewDeployOptions        | ❌       |                      | Sentry release deployment settings, see details below                                                                                                                                                                                                 |\n| sourceMaps                 | SentryCliUploadSourceMapsOptions | ✅       |                      | Sourcemaps settings, see details below                                                                                                                                                                                                                |\n| setCommits                 | SentryCliCommitsOptions          | ❌       |                      | Adds commits to sentry, see details below                                                                                                                                                                                                             |\n\n#### deploy settings\n\nWith `deploy` you can configure sentry cli to send deployment info. Here is a table of settings:\n\n| Option   | Type   | Required | Description                                                                          |\n| -------- | ------ | -------- | ------------------------------------------------------------------------------------ |\n| env      | string | ✅       | Environment value for release. For example `production`                            |\n| started  | number | ❌       | UNIX timestamp for deployment start                                                  |\n| finished | number | ❌       | UNIX timestamp for deployment finish                                                 |\n| time     | number | ❌       | Deployment duration in seconds. Can be used instead of `started` and `finished`. |\n| name     | string | ❌       | Human-readable name for this deployment                                              |\n| url      | string | ❌       | URL that points to the deployment                                                    |\n\n#### sourceMaps settings\n\nWith `sourceMaps` you can configure how sourcemaps will be processed\n\n| Option             | Type              | Required | Description                                                                                                                                                                                                                                           |\n| ------------------ | ----------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| include            | string\\| string[] | ✅       | One or more paths that Sentry CLI should scan recursively for sources. It will upload all `.map` files and match associated `.js` files.                                                                                                          |\n| dist               | string            | ❌       | Unique identifier for the distribution, used to further segment your release. Usually your build number                                                                                                                                               |\n| ignore             | string[]          | ❌       | Paths to ignore during upload. Overrides entries in `ignoreFile` file. If neither `ignoreFile` nor `ignore` is present, defaults to `['node_modules']`.                                                                                       |\n| ignoreFile         | string            | ❌       | Path to a file containing list of files/directories to ignore. Can point to `.gitignore` or anything with the same format.                                                                                                                          |\n| rewrite            | boolean           | ❌       | Enables rewriting of matching source maps so that indexed maps are flattened and missing sources are inlined if possible. Defaults to `true`                                                                                                        |\n| sourceMapReference | boolean           | ❌       | Prevents the automatic detection of sourcemap references. Defaults to `false`.                                                                                                                                                                      |\n| stripPrefix        | string[]          | ❌       | When paired with `rewrite`, will remove a prefix from uploaded filenames. Useful for removing a path that is build-machine-specific.                                                                                                                |\n| stripCommonPrefix  | boolean           | ❌       | When paired with `rewrite`, will add `~` to the `stripPrefix` array. Defaults to `false`                                                                                                                                                      |\n| validate           | boolean           | ❌       | When `true`, attempts source map validation before upload if rewriting is not enabled. It will spot a variety of issues with source maps and cancel the upload if any are found. Defaults to `false` to prevent false positives canceling upload. |\n| urlPrefix          | string            | ❌       | URL prefix to add to the beginning of all filenames. Defaults to `~/` but you might want to set this to the full URL. This is also useful if your files are stored in a sub folder. eg: `url-prefix '~/static/js'`.                               |\n| urlSuffix          | string            | ❌       | URL suffix to add to the end of all filenames. Useful for appending query parameters.                                                                                                                                                                 |\n| ext                | string[]          | ❌       | The file extensions to be considered. By default the following file extensions are processed:`js`, `map`, `jsbundle`, and `bundle`.                                                                                                           |\n\n#### setCommits settings\n\nWith `setCommits` you can configure\n\n| Option         | Type    | Required                | Description                                                                                                                                                                                                               |\n| -------------- | ------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| repo           | string  | ✅`if auto === false` | The full git repo name as defined in Sentry. Required if `auto` option is not `true`, otherwise optional.                                                                                                             |\n| commit         | string  | ✅`if auto === false` | The current (most recent) commit in the release. Required if `auto` option is not `true`, otherwise optional.                                                                                                         |\n| previousCommit | string  | ❌                      | The last commit of the previous release. Defaults to the most recent commit of the previous release in Sentry, or if no previous release is found, 10 commits back from `commit`.                                       |\n| auto           | boolean | ❌                      | Automatically set `commit` and `previousCommit`. Defaults `commit` to `HEAD` and `previousCommit` as described above. Overrides other options                                                                   |\n| ignoreMissing  | boolean | ❌                      | When the flag is set and the previous release commit was not found in the repository, will create a release with the default commits count(or the one specified with `--initial-depth`) instead of failing the command. |\n| ignoreEmpty    | boolean | ❌                      | When the flag is set, command will not fail and just exit silently if no new commits for a given release have been found.                                                                                                 |\n\n## Tests\n\nAt the moment we got unit tests for plugin functions. You can run them by running `yarn test`\n\nAlso there will appear e2e tests soon.\n\n## Author\n\n👤 **ikenfin**\n\n* Website: https://ikfi.ru\n* Github: [@ikenfin](https://github.com/ikenfin)\n\n## Thanks\n\nThank you to all contributors and users of this plugin. Knowing that so many people found this plugin helpful is really motivating me!\n\n## Show your support\n\nGive a ⭐️ if this project helped you!\n\n---\n\n_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikenfin%2Fvite-plugin-sentry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fikenfin%2Fvite-plugin-sentry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fikenfin%2Fvite-plugin-sentry/lists"}