{"_id":"@allardy/vite-plugin-sentry","name":"@allardy/vite-plugin-sentry","dist-tags":{"latest":"1.2.1"},"versions":{"1.2.1":{"name":"@allardy/vite-plugin-sentry","description":"The unofficial Sentry plugin for Vite ⚡️","version":"1.2.1","author":{"name":"ikenfin"},"license":"MIT","main":"./dist/index.js","module":"./dist/index.mjs","exports":{"types":"./index.d.ts","import":"./dist/index.mjs","default":"./dist/index.js"},"homepage":"https://github.com/ikenfin/vite-plugin-sentry","repository":{"type":"git","url":"git+https://github.com/ikenfin/vite-plugin-sentry.git"},"keywords":["vite-plugin","sentry","sentry-cli","sourcemap"],"scripts":{"bundle":"cross-env NODE_ENV=production rollup -c","dev":"cross-env NODE_ENV=develop rollup -c","test":"jest ./src/*/**.test.ts","test:coverage":"jest --coverage ./src/*/**.test.ts","lint":"eslint ./src/**/*.ts","lint:tests":"eslint ./src/**/*.test.ts","prepare":"is-ci || husky install"},"devDependencies":{"@rollup/plugin-commonjs":"24.1.0","@rollup/plugin-eslint":"^9.0.0","@rollup/plugin-typescript":"^11.0.0","@types/jest":"^28.1.4","@types/node":"^18.0.1","@typescript-eslint/eslint-plugin":"5.58.0","@typescript-eslint/parser":"5.58.0","cross-env":"^7.0.3","eslint":"8.38.0","husky":"^8.0.0","is-ci":"^3.0.1","jest":"28.1.3","prettier":"2.8.7","rollup":"3.20.4","ts-jest":"^28.0.5","typescript":"5.0.4"},"dependencies":{"@sentry/cli":"^2.3.1"},"peerDependencies":{"vite":"^2.6.0 || ^3.0.0 || ^4.0.0"},"engines":{"node":">= 12"},"bugs":{"url":"https://github.com/ikenfin/vite-plugin-sentry/issues"},"gitHead":"8fa3a3f3588efc530e1290d07f445a9a2d8c2cb2","_id":"@allardy/vite-plugin-sentry@1.2.1","_nodeVersion":"18.14.2","_npmVersion":"9.5.0","dist":{"integrity":"sha512-5L+UJejmoTnKKFxcRKMvARyqD4anjmRrXl0mLLsDB1L55gg2IwavgmEmme+amn3dX4j5SKpZl9EEVNG9Zq7llQ==","shasum":"34b22773d02dc864f9a842828c18988261c00038","tarball":"https://registry.npmjs.org/@allardy/vite-plugin-sentry/-/vite-plugin-sentry-1.2.1.tgz","fileCount":8,"unpackedSize":79684,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEFNWc4L1sENvu5WiIr6AirZiPpXMlpjsz9nV+hkfWVUAiB0+SZEzYSAGGsMkhWcw5ZtBSRXdCWVaysAfRANjfJcVA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJkPt+VACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrvdw//drcz20e6W6SKAZ4bZqqD/8d3u5x33meZyx2iHzrWOcRQKn4G\r\nPbGyMCb+E/L1SJen3CUYFssKt8ptQYXeZCJ2vy2EaqARrrbqs98o1exVtL6H\r\n2zHx38tHGwWayicCFk6NYdIW6jjbqgPuHlASOki89r3+Wg/zjKmhrO5PMk6m\r\na0YEDSuJ2Av5WONIMFn1mrseF0wwIDnMVjIhbpP0J51eJAXI96IGyZSBawQi\r\n6q5qBu4AJhXbQ/1QkDlemRczMHwQwBFOAZhMMBEeRMFj0wv/ozNKPnKT8rAP\r\np+G5mPlfg6vaR5LzZOKWx7o7dcLcr9NR6PypPD2fMXOwTFUhxGZcpc52kDT3\r\n3fxSl8q0wperjPy2dEEAxuhN70hdbDA9/uwyloMy0zXgyw/YaBxlARpLTHOn\r\nGUn2aujODVsm4+UG0Ts1eLZeV/iEflPq82rVJXsojzrS+M1AeBLXvVTRwWtY\r\nhOU7QXXmeMFMfbzNjKaTuSP1bSNQItpG8fosGKEVZUub49iRScy2oD5qUZGE\r\nGhObi7089aBj7HL7Gu+9AMDUzCFI3KzaXj39728pPWKIq37LW/5ZA/biWQ1K\r\nlx51ml+5C/0qouqPoM4gUFFA/0Yomdkbu+/62Da45Tm9F1/LgdX8j7jdNyKS\r\nx28CimcLcg97DAjYbRPqpDLC0h3iU3Xh8+Y=\r\n=RHat\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"allardy","email":"yann.allard1@gmail.com"},"directories":{},"maintainers":[{"name":"allardy","email":"yann.allard1@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vite-plugin-sentry_1.2.1_1681842069567_0.6628754925349192"},"_hasShrinkwrap":false}},"time":{"created":"2023-04-18T18:21:09.503Z","1.2.1":"2023-04-18T18:21:09.773Z","modified":"2023-04-18T18:21:09.944Z"},"maintainers":[{"name":"allardy","email":"yann.allard1@gmail.com"}],"description":"The unofficial Sentry plugin for Vite ⚡️","homepage":"https://github.com/ikenfin/vite-plugin-sentry","keywords":["vite-plugin","sentry","sentry-cli","sourcemap"],"repository":{"type":"git","url":"git+https://github.com/ikenfin/vite-plugin-sentry.git"},"author":{"name":"ikenfin"},"bugs":{"url":"https://github.com/ikenfin/vite-plugin-sentry/issues"},"license":"MIT","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> 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: '<SECRET_TOKEN_HERE>',\n  org: 'my_org',\n  project: 'my_project',\n  release: '1.0',\n  // legacyErrorHandlingMode: true, <- warn about sentry errors instead of fail\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 `&&` 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///<reference types=\"vite-plugin-sentry/client\"/>\n```\n\n## Common how to:\n\n#### Delete generated source maps after upload (#1)\n\nThere are no built-in options to clean sourcemaps.\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 && 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| 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","readmeFilename":"README.md"}