{"id":22828,"library":"vite-plugin-sentry","title":"vite-plugin-sentry","description":"Unofficial Sentry plugin for Vite that creates releases and uploads sourcemaps during the Vite build process, using @sentry/cli. Version 1.4.1 supports Vite 2.6–6.x and Node >=14. Built on TypeScript with full type definitions. Unlike the official webpack plugin, it offers virtual module integration to share release/dist config with the Sentry client, and optional automatic commit tracking and deployment environment configuration. Known for breaking changes in error handling (1.2.0) and deprecation of virtual module paths (1.1.5).","status":"active","version":"1.4.1","language":"javascript","source_language":"en","source_url":"https://github.com/ikenfin/vite-plugin-sentry","tags":["javascript","vite-plugin","sentry","sentry-cli","sourcemap"],"install":[{"cmd":"npm install vite-plugin-sentry","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-sentry","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-sentry","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin hooks into Vite's build process.","package":"vite","optional":false}],"imports":[{"note":"Default export for the plugin function. ESM-only since v1.1.6; CommonJS require may fail.","wrong":"const viteSentry = require('vite-plugin-sentry')","symbol":"viteSentry","correct":"import viteSentry from 'vite-plugin-sentry'"},{"note":"TypeScript type import; do not use runtime import as it will be undefined in JS. Available since v1.1.0.","wrong":"import { ViteSentryPluginOptions } from 'vite-plugin-sentry'","symbol":"ViteSentryPluginOptions","correct":"import type { ViteSentryPluginOptions } from 'vite-plugin-sentry'"},{"note":"Use virtual module to expose release/dist. The old path 'sentry-release' was deprecated in v1.1.5 and removed later.","wrong":"import config from 'virtual:vite-plugin-sentry/sentry-release'","symbol":"virtual:vite-plugin-sentry/sentry-config","correct":"import 'virtual:vite-plugin-sentry/sentry-config'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport viteSentry from 'vite-plugin-sentry';\n\nexport default defineConfig({\n  plugins: [\n    viteSentry({\n      url: 'https://sentry.io',\n      authToken: process.env.SENTRY_AUTH_TOKEN ?? '',\n      org: 'my_org',\n      project: 'my_project',\n      release: '1.0',\n      deploy: { env: 'production' },\n      setCommits: { auto: true },\n      sourceMaps: {\n        include: ['./dist/assets'],\n        ignore: ['node_modules'],\n        urlPrefix: '~/assets'\n      }\n    })\n  ],\n  build: { sourcemap: true }\n});","lang":"typescript","description":"Shows Vite config with vite-plugin-sentry, including auth token from env, sourcemaps, commit tracking, and deployment environment."},"warnings":[{"fix":"Add legacyErrorHandlingMode: true to plugin options.","message":"Since v1.2.0, Sentry upload errors crash the build instead of printing warnings. Use legacyErrorHandlingMode: true to revert.","severity":"breaking","affected_versions":">=1.2.0"},{"fix":"Replace 'sentry-release' with 'sentry-config' in imports.","message":"Virtual module path 'virtual:vite-plugin-sentry/sentry-release' is deprecated since v1.1.5 and may be removed. Use 'virtual:vite-plugin-sentry/sentry-config' instead.","severity":"deprecated","affected_versions":">=1.1.5"},{"fix":"Add sourcemap: true to Vite build options.","message":"Plugin requires build.sourcemap: true in Vite config to generate sourcemaps for upload. Missing this will cause no sourcemaps to be uploaded.","severity":"gotcha","affected_versions":"all"},{"fix":"Add \"types\": [\"vite-plugin-sentry/client\"] in tsconfig.json.","message":"In TypeScript, you must add 'vite-plugin-sentry/client' to tsconfig types or use a reference directive to get types for the virtual module and import.meta.env.","severity":"gotcha","affected_versions":">=1.1.0"},{"fix":"Use import or upgrade Node to >=14.","message":"From v1.1.6, the package uses .mjs for module entry and supports both ESM and CJS via conditional exports. CommonJS require() may not work in older Node versions (<14).","severity":"gotcha","affected_versions":">=1.1.6"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Set authToken in plugin options or export SENTRY_AUTH_TOKEN environment variable.","cause":"Missing or invalid authToken in config or environment.","error":"Error: Could not read auth token. Run 'sentry-cli login' or set the SENTRY_AUTH_TOKEN environment variable."},{"fix":"Generate a new auth token in Sentry with 'project:write' and 'org:integrations' scopes.","cause":"Sentry auth token lacks permissions (project:write or org:integrations).","error":"[vite-plugin-sentry] Sourcemaps upload failed: HTTP 403 Forbidden"},{"fix":"Ensure import 'virtual:vite-plugin-sentry/sentry-config' is at the top of your entry file.","cause":"Virtual module 'virtual:vite-plugin-sentry/sentry-config' not imported before accessing import.meta.env.VITE_PLUGIN_SENTRY_CONFIG.","error":"Uncaught TypeError: Cannot read properties of undefined (reading 'dist')"},{"fix":"Install vite-plugin-sentry as a dev dependency: npm install -D vite-plugin-sentry. Ensure tsconfig.json includes node_modules in typeRoots.","cause":"Missing or mismatched package installation; or TypeScript cannot resolve types.","error":"Cannot find module 'vite-plugin-sentry' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}