Documentation
This commit is contained in:
parent
33ce331413
commit
52e1fa2b6f
13 changed files with 270 additions and 64 deletions
|
@ -1,19 +1,53 @@
|
|||
import { defineNuxtModule, addPlugin, createResolver } from '@nuxt/kit'
|
||||
import { defineNuxtModule, addPlugin, addImports, createResolver, useLogger } from '@nuxt/kit'
|
||||
import { defu } from 'defu'
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
// Module options TypeScript interface definition
|
||||
export interface ModuleOptions {}
|
||||
const logger = useLogger('nuxt:wideangle')
|
||||
|
||||
export interface ModuleOptions {
|
||||
siteId?: string
|
||||
domain?: string
|
||||
fingerprint?: boolean
|
||||
supressDnt?: boolean
|
||||
includeParams?: string[]
|
||||
excludePaths?: string[]
|
||||
ignoreHash?: boolean
|
||||
}
|
||||
|
||||
export default defineNuxtModule<ModuleOptions>({
|
||||
meta: {
|
||||
name: 'wideangle',
|
||||
configKey: 'myModule'
|
||||
configKey: 'wideangle',
|
||||
compatibility: {
|
||||
nuxt: '^3'
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
domain: "stats.wideangle.co",
|
||||
fingerprint: false,
|
||||
supressDnt: false,
|
||||
includeParams: [],
|
||||
excludePaths: [],
|
||||
ignoreHash: false
|
||||
},
|
||||
// Default configuration options of the Nuxt module
|
||||
defaults: {},
|
||||
setup (options, nuxt) {
|
||||
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
|
||||
nuxt.options.build.transpile.push(runtimeDir)
|
||||
|
||||
logger.info(`Module options: ${JSON.stringify(options)}`);
|
||||
const resolver = createResolver(import.meta.url)
|
||||
|
||||
// Do not add the extension since the `.ts` will be transpiled to `.mjs` after `npm run prepack`
|
||||
addPlugin(resolver.resolve('./runtime/plugin'))
|
||||
nuxt.options.runtimeConfig.public.wideangle = defu(nuxt.options.runtimeConfig.public.wideangle, options);
|
||||
|
||||
addImports({
|
||||
name: "useWaaEvent",
|
||||
as: "useWaaEvent",
|
||||
from: resolver.resolve('./runtime/composables/useWaaEvent')
|
||||
});
|
||||
|
||||
addPlugin({
|
||||
src: resolver.resolve('./runtime/plugin.client')
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue