Skip to content

Commit 1a82caa

Browse files
authored
Merge pull request #25 from tanukijs-forks/main
Allow user to define `clientId` in runtimeConfig directly
2 parents 3ccd272 + c6a63d4 commit 1a82caa

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

package-lock.json

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
],
6969
"dependencies": {
7070
"@nuxt/kit": "^3.10.0",
71+
"defu": "^6.1.4",
7172
"unimport": "^3.7.1",
7273
"vue3-google-signin": "latest"
7374
},

src/module.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { resolve } from 'path'
22
import { fileURLToPath } from 'url'
33
import {
4-
defineNuxtModule,
5-
addPlugin,
64
addComponent,
7-
useLogger,
8-
addImportsSources
5+
addImportsSources,
6+
addPlugin,
7+
defineNuxtModule,
8+
useLogger
99
} from '@nuxt/kit'
10+
import { defu } from 'defu'
1011
import { defineUnimportPreset } from 'unimport'
1112

1213
const MODULE_NAME = 'nuxt-vue3-google-signin'
@@ -34,16 +35,17 @@ export default defineNuxtModule<ModuleOptions>({
3435
clientId: ''
3536
},
3637
setup (options, nuxt) {
37-
if (isEmpty(options.clientId)) {
38+
nuxt.options.runtimeConfig.public.googleSignIn = defu(
39+
nuxt.options.runtimeConfig.public.googleSignIn,
40+
{ clientId: options.clientId }
41+
)
42+
43+
if (isEmpty(nuxt.options.runtimeConfig.public.googleSignIn.clientId)) {
3844
useLogger(MODULE_NAME).error(
3945
'provide googleSignIn.clientId in appConfig'
4046
)
4147
}
4248

43-
nuxt.options.runtimeConfig.public.googleSignIn = {
44-
clientId: options.clientId
45-
}
46-
4749
const runtimeDir = fileURLToPath(new URL('./runtime', import.meta.url))
4850
nuxt.options.build.transpile.push(runtimeDir)
4951
addPlugin(resolve(runtimeDir, 'plugin'))

0 commit comments

Comments
 (0)