diff --git a/src/module.ts b/src/module.ts index e487cf0..2315d44 100644 --- a/src/module.ts +++ b/src/module.ts @@ -1,5 +1,7 @@ import { defineNuxtModule, createResolver, addServerPlugin, addTypeTemplate, addPlugin } from '@nuxt/kit' import { resolvePath } from "mlly" +import { defu } from 'defu' +import type { RuntimeConfig } from '@nuxt/schema' export interface ModuleOptions { /** @@ -45,6 +47,19 @@ export default defineNuxtModule({ references.push({ path: resolver.resolve('./runtime/types.d.ts') }) }) + if (options.connectionString) { + nuxt.options.runtimeConfig = defu(nuxt.options.runtimeConfig, { + public: { + applicationinsights: { + connectionString: options.connectionString + } + }, + applicationinsights: { + connectionString: options.connectionString + } + }) as RuntimeConfig + } + if (options.serverEnabled) { nuxt.options.nitro.modules = nuxt.options.nitro.modules || [] nuxt.options.nitro.modules.push(await resolvePath('nitro-applicationinsights'))