fix(nuxt): add `payload.client` plugin only for production build (#7498)

This commit is contained in:
pooya parsa 2022-09-14 15:01:02 +02:00 committed by GitHub
parent ac0b3a63a2
commit 9024d76165
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import { defineNuxtPlugin, loadPayload, addRouteMiddleware, isPrerendered } from
export default defineNuxtPlugin((nuxtApp) => { export default defineNuxtPlugin((nuxtApp) => {
// Only enable behavior if initial page is prerendered // Only enable behavior if initial page is prerendered
// TOOD: Support hybrid // TOOD: Support hybrid and dev
if (!isPrerendered()) { if (!isPrerendered()) {
return return
} }

View File

@ -174,7 +174,9 @@ async function initNuxt (nuxt: Nuxt) {
}) })
// Add prerender payload support // Add prerender payload support
if (!nuxt.options.dev) {
addPlugin(resolve(nuxt.options.appDir, 'plugins/payload.client')) addPlugin(resolve(nuxt.options.appDir, 'plugins/payload.client'))
}
// Track components used to render for webpack // Track components used to render for webpack
if (nuxt.options.builder === '@nuxt/webpack-builder') { if (nuxt.options.builder === '@nuxt/webpack-builder') {