fix: Move back store hydration before plugins execution

This commit is contained in:
Sebastien Chopin 2017-09-06 15:15:25 +02:00
parent 251d87914d
commit 79a64df422
2 changed files with 7 additions and 10 deletions

View File

@ -135,13 +135,6 @@ async function createApp (ssrContext) {
<% } %> <% } %>
} }
<% plugins.filter(p => p.ssr).forEach(plugin => { %>
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %>
<% if (plugins.filter(p => !p.ssr).length) { %>
if (process.browser) { <% plugins.filter(p => !p.ssr).forEach(plugin => { %>
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %>
}<% } %>
<% if (store) { %> <% if (store) { %>
if (process.browser) { if (process.browser) {
// Replace store state after calling plugins // Replace store state after calling plugins
@ -151,6 +144,13 @@ async function createApp (ssrContext) {
} }
<% } %> <% } %>
<% plugins.filter(p => p.ssr).forEach(plugin => { %>
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %>
<% if (plugins.filter(p => !p.ssr).length) { %>
if (process.browser) { <% plugins.filter(p => !p.ssr).forEach(plugin => { %>
if (typeof <%= plugin.name %> === 'function') await <%= plugin.name %>(ctx, inject)<% }) %>
}<% } %>
if (process.server && ssrContext && ssrContext.url) { if (process.server && ssrContext && ssrContext.url) {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
router.push(ssrContext.url, resolve, reject) router.push(ssrContext.url, resolve, reject)

View File

@ -110,9 +110,6 @@ export function getContext (context, app) {
} }
if (ctx.isClient && window.__NUXT__) { if (ctx.isClient && window.__NUXT__) {
ctx.serverState = window.__NUXT__ ctx.serverState = window.__NUXT__
<% if (store) { %>
ctx.serverStoreState = ctx.serverState.state
<% } %>
} }
return ctx return ctx
} }