Skip to content

Commit eefb179

Browse files
committed
feat(nuxt): Wrap config in nuxt context
1 parent 615c670 commit eefb179

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/nuxt/src/module.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ export default defineNuxtModule<ModuleOptions>({
2626
addPluginTemplate({
2727
mode: 'client',
2828
filename: 'sentry-client-config.mjs',
29-
getContents: () =>
30-
`import "${buildDirResolver.resolve(`/${clientConfigFile}`)}"\n` +
31-
'import { defineNuxtPlugin } from "#imports"\n' +
32-
'export default defineNuxtPlugin(() => {})',
29+
30+
// Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin)
31+
// Makes it possible to call useRuntimeConfig() in the user-defined sentry config file
32+
getContents: () => `
33+
import { defineNuxtPlugin } from "#imports";
34+
35+
export default defineNuxtPlugin(async () => {
36+
await import("${buildDirResolver.resolve(`/${clientConfigFile}`)}")
37+
});`,
3338
});
3439

3540
addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'), mode: 'client' });

0 commit comments

Comments
 (0)