From bc29d88ec561a910be5eaa4f671e97f86184fda3 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 16 May 2024 15:10:43 +0200 Subject: [PATCH] ref(sveltekit): Warn to delete source maps if Sentry plugin enabled source maps generation (#12072) Now we can at least recommend to use `filesToDeleteAfterUpload` since we bumped to vite plugin 2.x with 8.0.0 --- packages/sveltekit/src/vite/sourceMaps.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/sveltekit/src/vite/sourceMaps.ts b/packages/sveltekit/src/vite/sourceMaps.ts index eb97a3e4a7c6..5b9e2d355cfa 100644 --- a/packages/sveltekit/src/vite/sourceMaps.ts +++ b/packages/sveltekit/src/vite/sourceMaps.ts @@ -103,8 +103,18 @@ export async function makeCustomSentryVitePlugins(options?: CustomSentryVitePlug // Modify the config to generate source maps config: config => { - // eslint-disable-next-line no-console - debug && console.log('[Source Maps Plugin] Enabeling source map generation'); + const sourceMapsPreviouslyEnabled = !config.build?.sourcemap; + if (debug && sourceMapsPreviouslyEnabled) { + // eslint-disable-next-line no-console + console.log('[Source Maps Plugin] Enabeling source map generation'); + if (!mergedOptions.sourcemaps?.filesToDeleteAfterUpload) { + // eslint-disable-next-line no-console + console.warn( + `[Source Maps Plugin] We recommend setting the \`sourceMapsUploadOptions.sourcemaps.filesToDeleteAfterUpload\` option to clean up source maps after uploading. +[Source Maps Plugin] Otherwise, source maps might be deployed to production, depending on your configuration`, + ); + } + } return { ...config, build: {