File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
packages/sveltekit/src/vite Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -76,9 +76,26 @@ export async function makeCustomSentryVitePlugins(options?: CustomSentryVitePlug
7676 const defaultFileDeletionGlob = [ './.*/**/*.map' , `./${ adapterOutputDir } /**/*.map` ] ;
7777
7878 if ( ! globalWithSourceMapSetting . _sentry_sourceMapSetting ) {
79- // @ts -expect-error - the dynamic import here works fine
80- const Vite = await import ( 'vite' ) ;
81- const configFile = await Vite . loadConfigFromFile ( { command : 'build' , mode : 'production' } ) ;
79+ let configFile : {
80+ path : string ;
81+ config : UserConfig ;
82+ dependencies : string [ ] ;
83+ } | null = null ;
84+
85+ try {
86+ // @ts -expect-error - the dynamic import here works fine
87+ const Vite = await import ( 'vite' ) ;
88+ configFile = await Vite . loadConfigFromFile ( { command : 'build' , mode : 'production' } ) ;
89+ } catch {
90+ if ( options ?. debug ) {
91+ consoleSandbox ( ( ) => {
92+ // eslint-disable-next-line no-console
93+ console . warn (
94+ '[Sentry] Could not import Vite to load your vite config. Please set `build.sourcemap` to `true` or `hidden` to enable source map generation.' ,
95+ ) ;
96+ } ) ;
97+ }
98+ }
8299
83100 if ( configFile ) {
84101 globalWithSourceMapSetting . _sentry_sourceMapSetting = getUpdatedSourceMapSetting ( configFile . config ) ;
You can’t perform that action at this time.
0 commit comments