-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmodule.ts
57 lines (50 loc) · 1.52 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
47
48
49
50
51
52
53
54
55
56
57
import { join } from 'node:path'
import {
addImportsDir,
addPlugin,
createResolver,
defineNuxtModule,
} from '@nuxt/kit'
import defu from 'defu'
import { name, version } from '../package.json'
import type { OptionPlugin } from './runtime/vue'
export interface ModuleOptions extends OptionPlugin {}
export default defineNuxtModule<ModuleOptions>({
meta: {
name,
version,
configKey: 'chatwoot',
compatibility: {
nuxt: '^3.3.1',
},
},
defaults: {
init: {
// eslint-disable-next-line node/prefer-global/process
websiteToken: process.env.CHATWOOT_TOKEN as string || '',
/* In this code, `process` is a global object in Node.js that provides information and
control over the current Node.js process. It allows you to access environment
variables, command-line arguments, and other process-related information. */
// eslint-disable-next-line node/prefer-global/process
baseUrl: process.env.CHATWOOT_URL || 'https://app.chatwoot.com',
},
partytown: false,
},
setup(options, nuxt) {
const { resolve } = createResolver(import.meta.url)
nuxt.options.runtimeConfig.public.chatwoot = defu(
nuxt.options.runtimeConfig.public.chatwoot,
options,
)
const runtimeDir = resolve('./runtime')
addImportsDir(join(runtimeDir, 'composables'))
addPlugin({ src: join(runtimeDir, 'plugin'), mode: 'client' })
},
})
declare module '@nuxt/schema' {
interface ConfigSchema {
publicRuntimeConfig?: {
chatwoot?: ModuleOptions
}
}
}