mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 01:53:55 +00:00
fix(nuxt): guard window
access more carefully
This commit is contained in:
parent
1dc51668a4
commit
977377777a
@ -7,6 +7,8 @@ import { defineNuxtPlugin } from '../nuxt'
|
|||||||
import { devLogs, devRootDir } from '#build/nuxt.config.mjs'
|
import { devLogs, devRootDir } from '#build/nuxt.config.mjs'
|
||||||
|
|
||||||
export default defineNuxtPlugin((nuxtApp) => {
|
export default defineNuxtPlugin((nuxtApp) => {
|
||||||
|
if (!import.meta.client || import.meta.test) { return }
|
||||||
|
|
||||||
// Show things in console
|
// Show things in console
|
||||||
if (devLogs !== 'silent') {
|
if (devLogs !== 'silent') {
|
||||||
const logger = createConsola({
|
const logger = createConsola({
|
||||||
@ -41,7 +43,7 @@ export default defineNuxtPlugin((nuxtApp) => {
|
|||||||
|
|
||||||
// pass SSR logs after hydration
|
// pass SSR logs after hydration
|
||||||
nuxtApp.hooks.hook('app:suspense:resolve', async () => {
|
nuxtApp.hooks.hook('app:suspense:resolve', async () => {
|
||||||
if (window && window.__NUXT_LOGS__) {
|
if (typeof window !== 'undefined' && window.__NUXT_LOGS__) {
|
||||||
await nuxtApp.hooks.callHook('dev:ssr-logs', window.__NUXT_LOGS__)
|
await nuxtApp.hooks.callHook('dev:ssr-logs', window.__NUXT_LOGS__)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user