/
module.ts
46 lines (39 loc) · 1.03 KB
/
module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {
addImportsDir,
addPlugin,
createResolver,
defineNuxtModule,
} from '@nuxt/kit'
import { name, version } from '../package.json'
import { defu } from 'defu'
export const CONFIG_KEY = 'typo3Matomo'
export interface ModuleOptions {
domains: string
matomoUrl: string
siteId: number
}
export default defineNuxtModule<ModuleOptions>({
defaults: {
domains: '',
matomoUrl: '',
siteId: 0,
},
meta: {
configKey: CONFIG_KEY,
name,
version,
},
setup(options, nuxt) {
const resolver = createResolver(import.meta.url)
nuxt.options.alias['#nuxt-typo3-matomo'] = resolver.resolve('runtime')
nuxt.options.runtimeConfig.public[CONFIG_KEY] = defu(
nuxt.options.runtimeConfig.public[CONFIG_KEY],
options,
)
addImportsDir(resolver.resolve('runtime/composables/**/*'))
addPlugin({
mode: 'client',
src: resolver.resolve('./runtime/plugins/matomo'),
})
},
})