diff --git a/packages/sveltekit/src/vite/sentryVitePlugins.ts b/packages/sveltekit/src/vite/sentryVitePlugins.ts index 0f2461a419de..1f983d7a9653 100644 --- a/packages/sveltekit/src/vite/sentryVitePlugins.ts +++ b/packages/sveltekit/src/vite/sentryVitePlugins.ts @@ -78,7 +78,7 @@ export async function sentrySvelteKit(options: SentrySvelteKitPluginOptions = {} ); } - if (mergedOptions.autoUploadSourceMaps) { + if (mergedOptions.autoUploadSourceMaps && process.env.NODE_ENV !== 'development') { const pluginOptions = { ...mergedOptions.sourceMapsUploadOptions, debug: mergedOptions.debug, // override the plugin's debug flag with the one from the top-level options diff --git a/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts b/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts index f606b5ee6e9a..963844bdef70 100644 --- a/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts +++ b/packages/sveltekit/test/vite/sentrySvelteKitPlugins.test.ts @@ -38,6 +38,19 @@ describe('sentryVite()', () => { expect(plugins).toHaveLength(1); }); + it("doesn't return the custom sentry source maps plugin if `NODE_ENV` is development", async () => { + const previousEnv = process.env.NODE_ENV; + + process.env.NODE_ENV = 'development'; + const plugins = await sentrySvelteKit({ autoUploadSourceMaps: true, autoInstrument: true }); + const instrumentPlugin = plugins[0]; + + expect(plugins).toHaveLength(1); + expect(instrumentPlugin.name).toEqual('sentry-auto-instrumentation'); + + process.env.NODE_ENV = previousEnv; + }); + it("doesn't return the auto instrument plugin if autoInstrument is `false`", async () => { const plugins = await sentrySvelteKit({ autoInstrument: false }); expect(plugins).toHaveLength(1);