diff --git a/packages/nuxt/src/module.ts b/packages/nuxt/src/module.ts index 11b9e5ce2ff4..813fb9385066 100644 --- a/packages/nuxt/src/module.ts +++ b/packages/nuxt/src/module.ts @@ -74,20 +74,6 @@ export default defineNuxtModule({ mode: 'client', order: 1, }); - - // Add the sentry config file to the include array - nuxt.hook('prepare:types', options => { - const tsConfig = options.tsConfig as { include?: string[] }; - - if (!tsConfig.include) { - tsConfig.include = []; - } - - // Add type references for useRuntimeConfig in root files for nuxt v4 - // Should be relative to `root/.nuxt` - const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile); - tsConfig.include.push(relativePath); - }); } const serverConfigFile = findDefaultSdkInitFile('server', nuxt); @@ -134,6 +120,26 @@ export default defineNuxtModule({ addDatabaseInstrumentation(nuxt.options.nitro); } + // Add the sentry config file to the include array + nuxt.hook('prepare:types', options => { + const tsConfig = options.tsConfig as { include?: string[] }; + + if (!tsConfig.include) { + tsConfig.include = []; + } + + // Add type references for useRuntimeConfig in root files for nuxt v4 + // Should be relative to `root/.nuxt` + if (clientConfigFile) { + const relativePath = path.relative(nuxt.options.buildDir, clientConfigFile); + tsConfig.include.push(relativePath); + } + if (serverConfigFile) { + const relativePath = path.relative(nuxt.options.buildDir, serverConfigFile); + tsConfig.include.push(relativePath); + } + }); + nuxt.hooks.hook('nitro:init', nitro => { if (nuxt.options?._prepare) { return;